# By default, make every data type compatible with list blocks

Personally I think “[] in front of {list}” should be vardradic
Id really love this especially if we got

The “in front of” would disappear if you press the arrow

This would be super useful to make it so you don’t have to do

When ever you want to make a list

Heres my definition of the block if you wanna play around with it

I never actually showed the definition lol

well you can just put an IN FRONT OF block in the second input of another IN FRONT OF block. and for behind, use the APPEND block.

Yea but what is cleaner

Good point.

Maybe you could try using the in front of block recursively for the definition of the variadic version

Or you can use append

But it just kinda makes sense

You can still make the custom block, it's just easier (and probably faster) to use append instead of recursion.

Yea but the custom block is cumbersome if you just want to use in front of, or just want to use behing

That is a good idea, i love it, i mean, you could use append, but i hate that append is not compatible with any other data type expect lists.

Yea, it just makes sense to have it like this
We could even technically remove the append block but I don’t see a reason to do that

I mean, if append could be just more smart (would work with every data type), then actually in front of would be deleted lol

Here is my enhanced append

Here is my enhanced append

Jokes aside, enhanced append would look like this

oops

I think this block works for a very specific use case. I don’t quite know what that is, because it converts [0, [[a, b], [c, d]]] into [0, [a, b], [c, d]], and I have no idea what the applications of that are.

Umm. This is going to be a long story and y'all probably won't like it.

IN FRONT OF and ALL BUT FIRST OF are in Snap! to help teach how to write recursive functions, like this:

or, to leave out the slight complexity of CALL,

The big idea here is that a list can be divided into its first (which is an item) and its all but first (which is a sublist). You apply the function you're interested in to the first item, and you make a recursive call for all but the first item.

(Really we should have a FIRST block in that group, to go with ALL BUT FIRST and IN FRONT OF.)

And the next big idea is that you need a base case that your program knows how to compute without making another recursive call.

There's lots more to say, e.g., about the domain and range of the recursive function, but I'm not writing a curriculum here. But a point it's worth making is that recursion isn't just a screwy way to write a loop; for example, consider this:

If you try to read this as a loop, you'll get very confused about the value of DATA. But, in a different way, it shows the power of dividing a list into its first item and the rest of the list.

And IN FRONT OF is the inverse function to FIRST and ALL BUT FIRST. That is,

is the same as L.

This set of three functions imposes a particular discipline on writing recursive functions of lists. So, for example, if you're grading exams in my course and you see ITEM 2 OF in the code, you know right away that the student doesn't really believe in recursion, and is trying to make the function being CALLed do the job of the recursive call. (Yes, you can construct artificial exceptions, and we do that in class too.)

Going along with this recursive discipline is the structure of a linked list, in which each cell contains one item and (a pointer to) a sublist.

So. It would defeat the object of the exercise if we gave you IN BACK OF, etc. Not that you can't write those yourselves, but they're not part of our story.

As for APPEND taking non-list inputs, let me commend to your attention the function SENTENCE, which you'll find in the List Utilities library as well as the Words and Sentences library.

Oh well that’s kind of funny

This topic was originally for what the title says but I forgot to change it