separate between elements

abd shared this question 1 year ago

if i have L={"a",2,3,"h"} and i want to separate between them Lnumber={2,3} & Lletters={a,h}

how ?

Comments (4)


I have test (successful) the following principle

- convert all in text

- convert the text in Unicode

- check is numeric (all character per element)

- save the index of numerical objecs in a separate list

- then extract the numerical objects from L with the Index above

- then extract the non-numerical objects from L (all other)

In Java-Script it's more ease: it's is possible to ask the object-type


this is not easy and expensive.

mixed object-types in the same list are not a good style (normally)

better: create separate lists for different object-types at the beginning

Note: when you can code the above principle, then is no problem for you to use the better style.

otherwise describe the problem and send the GGB file, presumably there is a solution.


plz can you do it


For me is not really clear what you need (if possible).


You have a text "2,4-dimethyl" and the first characters (until "-") you need as numerical value.

maybe as 2.4 or maybe as {2,4} and you need also "dimethyl" as seperated text object.

It's also very (!!) important to know how the text "2,4-dimethyl" is created (by user (for example input-box) or by applet (how) or something else)

or something else ??



The problem I assumed is not a normal problem in GGB. Normally you must use Java-Script and Regex() to separate and transform the type of objects. So it's also important to know the context of the applet (for example: create (by InputBox) a list with molecules and associated parameters or import a list (without mistakes) as text and separate the parameters)


When you think in solutions and you want ask only the syntax of your solution, you receive in many time not a good solution. Prefer to think in problems and describe the problems in a context.


ok ...thanks for your advice

© 2020 International GeoGebra Institute