scheme - Why do nested applications of cons construct improper lists? -


Do the nested apps of disasters create inappropriate lists? I am learning the plan and confused about it cons I have come to this answer:

I know that when opposition < The second argument of / code> is a list, then it adds the first logic to the top of the list

  (Opposition 1 (list2 3) => (1 2 3)   

I understand the following pair:

  (cons 2 3); 2.3 pair   

although I understand Can not find why the following expression creates inappropriate lists

  (1 1 2 .3); An inappropriate list   

I just can not express what is happening with the expression above

Can you please expand on that?

The illusion you are experiencing It's not unique. Just signaling is all this, and until you learn that notation, everything is confusing.

First of all, let's begin with the proper lists. There are lists which are empty Chi would end with:

  (cons 1 (cons 2 (cons 3 '()))); = & Gt; (1 2 3)   

This list is a short story for (1 2 3) , indeed (1 2 3) < / Code>: Originally a list where the last cons indicates for an empty list.

Now, if we replace () with 4, then see what we get:

  (Opposition 1 (Opposition 2 (Opposition 3-4)); = & Gt; (1 2 3 .4)   

Note that this is no different from (1 2 3. ()) , what is it?

Of course, both of these are short stories for very long form (1 (2. (3 () ())) and (1 (2. (3 .4))) , respectively.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -