wow, I’d never thought about this one!
“the docs imply that if the last argument isn’t a list that the result would be an improper list” It is producing an improper list.
I’m not clear what an improper list is
I thought (1 2 . 3)
Does ( . 3) evaluate to 3 ?
An improper list is one whose final cons cell doesn’t have null in the cdr.
(. 3)
is a read error
And finding all the exciting identity functions in Racket is a fun game.
Yes it is a read error but I don’t know how to express (append '() 1 )
well, turns out it’s 1
:smile:
Right, there’s no read syntax that just disappears like that
Should a do a pr for ‘append’in the racket reference? Something like;
> Note: (append '() n)
is an identity function.
I think that would be more confusing than helpful.
How about > Note: Appending to an empty list e.g. (append '() n)
is an identity function and will return the value of n
, not a list.
Did this bite you?
Yes. I was wanting to use a list to record a series of actions in a little pict-draw thing I am making as a learning exercise. (Each action is drawing a circle or rectangle with parameters) I came across this by accident
In any case I think I should be using an array…
Probably the issue is that the last element was supposed to be a list but was not, rather than (λ (x) (append '() x))
being the identity function?
(also note that (append '() a-list)
does of course return a-list
)
yes I made that mistake too
What I wanted (append commands-list new-command)
'()
=> (('circle 20 30 10))
What I got ('() 'circle 20 30 10)
:rolling_on_the_floor_laughing:
Heh :slightly_smiling_face:
Looks like a fork of racket-paint? :slightly_smiling_face: