Using reshape to get a matrix of empty lists

I'm wanting to use reshape to produce an initial matrix with cell value = zero length list
image

But the top line produces the 2nd line when I'm after the 3rd line

Any ideas?

I've come up with this myself
image

Hmm, I thought maybe
untitled script pic (6)
would do it, but no, if any of the numbers is zero you just get a single empty list.

Of course you can do it by TREEMAPping untitled script pic (7) over your result, but since TREEMAP isn't primitive, that won't be super fast.

Speed isn't an issue as it's just used for setting up a matrix
Where is treemap?

We should really add "blockify" as an option in the LENGTH-and-friends block, huh?

P.S. TREEMAP is my nominee for the world's most beautiful computer program.

That is a very nice block :slight_smile:

Can't remember having a need for that myself

Mostly for smart pic and metaprograming (from Metaprogramming library)

I see - yes that would nice to have :slight_smile:

I've just realised (by looking inside my own block) that my exisitng deep map saved block and your treemap are the same (I probably got it from you in the first place)

I had actually tried it out and it didn't work but didn't realise that I had to miss off the final 0 dimension :slight_smile:

This blockify block is really handy - def needs to be in core :slight_smile:

Very nice :slight_smile:

I'll use the call in future as it's the least effort to construct (and I understand how it works)

And I can see how number two does the job as well

But I'll have to think a bit about what's happening with no 1 :slight_smile:

whenever you see a loop, think map instead, and whenever you see map, think hyper!

I felt sure there would be a way to hyperize it, but I couldn't think of any of your beautiful ways. :~(

I find myself mindboggled by how the hyper way has changed my thinking

OK, been out for a bike ride and had lunch

So given this
replaceEmptyLists script pic (3)

makes sense if you imagine "letters" to be equivalent to "item" ( Suggestion add as a menu item to make it explicit)

And then if we replace the list with 2 empty slots we get this
replaceEmptyLists script pic (4)

but the thing that needs understanding is why we don't end up with
replaceEmptyLists script pic (5)

so the logic is that each original slot is "empty" and if those are converted to a list then those lists
are
replaceEmptyLists script pic (6)
and not
replaceEmptyLists script pic (7)

But I do struggle with the difference between an truly empty list and a list with one item that is empty :frowning:

Do other languages have this distinction?

well, splitting text reports a list of sub-texts. If the source text is empty, so is the result of "split", an empty list. Which part of your uneasiness do I not grasp?

In JavaScript

''.split('')

also returns an empty Array. Same idea...

The difference between an empty list and one with an item that is empty - I can't come up with a real-world analogy to let me fully comprehend the difference

Ah, I see. How about a carton of eggs, of which you've already eaten some? There is space for, say 10 eggs in the carton, but 2 are missing. The carton still has a size of 10. Does that help?

That nicely explains list(egg,egg,egg,egg,egg,egg,egg,egg,,) but what would list() look like in terms of cartons?

I've come up with something :slight_smile:

list() is an invisible carton that only becomes visible when you get it out of the cupboard!