List constructor with a variable of list elements?

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?
image

This is just one possible solution:

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:
    nlist0

  • And to build an empty list with n elements, yes @mr_piay is perfect. But I want to play "more functional". Something like

nlist2

Or just use our "functional blocks" as "map"

nlist3

Test this solutions, and the "imperative one", with a list of 100 or 1000 items... and you will see the difference!

Joan

Thanks @jguille2, what a difference!

Benvido, Javier!
Veo que eres de Vigo.
Saúdos de Barcelona,

Joan

Gràcies Joan :wink:

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.

  1. 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.
  2. @bh has read my mind like an execellent teacher. I wanted a way to create code.
  3. 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

I'm pretty sure @bh is an excellent teacher, but both @jguille2 and I also read your mind :wink: