I am trying to build a function, which returns a list constructor with an amount of slots/Liste elements as the parameter.
So my function
create_list_constructor(1) returns a list block with 1 slot
create_list_constructor(3) returns a list block with 3 slots
is this even possible?
I'm afraid you're asking something different...
You want a block that returns a block, right?
Hi @mr_piay, I think @kimmie46 wants a "real block" with that number of slots... But I want to comment both ideas...
-
About creating a Snap! bock... We can create blocks as data (they are first class) using Snap! rings methafor... but I think it is not what you want. But if you want a shortcut to create lists, I suggest you using "split" bock. You can use spaces or any character/s you want and get your lists easily.
Example using two white spaces:
-
And to build an empty list with n elements, yes @mr_piay is perfect. But I want to play "more functional". Something like
Or just use our "functional blocks" as "map"
Test this solutions, and the "imperative one", with a list of 100 or 1000 items... and you will see the difference!
Joan
Benvido, Javier!
Veo que eres de Vigo.
Saúdos de Barcelona,
Joan
Gràcies Joan
Reading your mind, as teachers must learn to do, I think that you don't really want a reporter at all. What you want is for a LIST block to appear in the scripting area, so you can fill it in with the desired list items. And, no, so far we don't have a way to create code in your program. It's one of the things on my very long term missing-feature list.
- Thanks to @mr_piay, @jguille2, for your quick reply! Gràcies! And sorry that I did not explain my request so good that it would be understandable.
- @bh has read my mind like an execellent teacher. I wanted a way to create code.
- I rephrased my request in a new question here: How to select a variable number of columns of a table and return a table?
THANKS again,
matthias