netraken wrote on 1/21/19 2:51 PM:
(define (enum-var-dim n v)
(if ( = n 2)
(cons (fst (cantor-enum v)) (snd (cantor-enum v)))
(cons (fst (cantor-enum v))(enum-var-dim (sub1 n) (snd
(cantor-enum v))))))
This is looking nicely Rackety. :)
Running
(enum-var-dim n value)
outputs me something of the form
'(5.0 8.0 . 6.0)
with one point between the last numbers. Where does it come from ?
That's an improper end to a list. It means a structure of pairs in
which the CDR (right element) of the last pair is not the null list.
> (cons 'a (cons 'b (cons 'c 'd)))
'(a b c . d)
When building up a list via `cons`, you want to start with the null
list, so you end up instead like this:
> (cons 'a (cons 'b (cons 'c (cons 'd '()))))
'(a b c d)
If you want to supplement Racket's discussion of pairs and lists (I
don't recall how much it said), basically any Scheme textbook will
work. SICP drew diagrams with boxes and arrows that can help.
https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book.html
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.