laurent.orseau
2020-11-27 09:22:29

wow, I’d never thought about this one!


dvanhorn
2020-11-27 15:27:00

“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.


spdegabrielle
2020-11-27 15:36:59

I’m not clear what an improper list is


spdegabrielle
2020-11-27 15:37:22

I thought (1 2 . 3)


spdegabrielle
2020-11-27 15:38:14

Does ( . 3) evaluate to 3 ?


samth
2020-11-27 15:38:48

An improper list is one whose final cons cell doesn’t have null in the cdr.


samth
2020-11-27 15:39:00

(. 3) is a read error


samth
2020-11-27 15:39:16

And finding all the exciting identity functions in Racket is a fun game.


spdegabrielle
2020-11-27 15:40:42

Yes it is a read error but I don’t know how to express (append '() 1 )


laurent.orseau
2020-11-27 15:40:59

well, turns out it’s 1 :smile:


samth
2020-11-27 15:41:26

Right, there’s no read syntax that just disappears like that


spdegabrielle
2020-11-27 15:43:21

Should a do a pr for ‘append’in the racket reference? Something like;

> Note: (append '() n) is an identity function.


laurent.orseau
2020-11-27 15:44:32

I think that would be more confusing than helpful.


spdegabrielle
2020-11-27 15:47:59

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.


laurent.orseau
2020-11-27 15:48:40

Did this bite you?


spdegabrielle
2020-11-27 15:50:54

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


spdegabrielle
2020-11-27 15:52:19

In any case I think I should be using an array…


laurent.orseau
2020-11-27 15:52:22

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?


laurent.orseau
2020-11-27 15:53:00

(also note that (append '() a-list) does of course return a-list)


spdegabrielle
2020-11-27 16:08:47

yes I made that mistake too


spdegabrielle
2020-11-27 16:12:37

What I wanted (append commands-list new-command) '()=> (('circle 20 30 10)) What I got ('() 'circle 20 30 10) :rolling_on_the_floor_laughing:


laurent.orseau
2020-11-27 18:54:14

Heh :slightly_smiling_face:


laurent.orseau
2020-11-27 18:55:29

Looks like a fork of racket-paint? :slightly_smiling_face: