Matthew F Posted October 13, 2013 Posted October 13, 2013 I'm wondering if someone could suggest a calculation to convert a list of numbers into a list of two digit numbers. For example: "1¶3¶9¶14¶22" would be converted to.. "01¶03¶09¶14¶22" In other words the single digit numbers would have a "0" placed in front. Thanks!
Matthew F Posted October 13, 2013 Author Posted October 13, 2013 I found a solution using Comment's custom function, "SubstituteValues".
comment Posted October 13, 2013 Posted October 13, 2013 Well, there are only 10 single-digit numbers (9 if you exclude 0) - so substituting them with their two-digit equivalents would seem like the cheapest way to go.
comment Posted October 13, 2013 Posted October 13, 2013 Just to clarify, I meant a straightforward hard-coded substitute, e.g. = Let ( [ sub = Substitute ( ¶ & listOfValues & ¶ ; [ "¶1¶" ; "¶01¶" ] ; [ "¶2¶" ; "¶02¶" ] ; [ "¶3¶" ; "¶03¶" ] ; ... [ "¶9¶" ; "¶09¶" ] ) ] ; Middle ( sub ; 2 ; Length ( sub ) - 2 ) ) The custom function is designed for cases where the substitution pairs are not known in advance - for example, when there is a table of dictionary terms that the users can modify. 2
Matthew F Posted October 17, 2013 Author Posted October 17, 2013 Awesome, thanks for the tip! I never would have figured out that last part: Middle ( sub ; 2 ; Length ( sub ) - 2 ) Without it, the substitute ignores the first value because it is not preceded by a newline character ("¶")
Recommended Posts
This topic is 4112 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now