learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-26.scm (755B)


      1 ;; Exercise 2.26
      2 
      3 ;; (define x (list 1 2 3))
      4 ;; (define y (list 4 5 6))
      5 ;; (append x y) => (1 2 3 4 5 6)
      6 ;; (cons x y) => ((1 2 3) 4 5 6)
      7 ;; (list x y) => ((1 2 3) (4 5 6))
      8 
      9 ;; scheme@(guile-user)> (define x (list 1 2 3))
     10 ;; scheme@(guile-user)> (define y (list 4 5 6))
     11 ;; scheme@(guile-user)> (append x y)
     12 ;; $1 = (1 2 3 4 5 6)
     13 ;; scheme@(guile-user)> (cons x y)
     14 ;; $2 = ((1 2 3) 4 5 6)
     15 ;; scheme@(guile-user)> (list x y)
     16 ;; $3 = ((1 2 3) (4 5 6))
     17 
     18 (let ([x (list 1 2 3)]
     19       [y (list 4 5 6)])
     20   (test-begin "2.26")
     21   (test-equal
     22       "(1 2 3 4 5 6)"
     23     (format #f "~a" (append x y)))
     24   (test-equal
     25       "((1 2 3) 4 5 6)"
     26     (format #f "~a" (cons x y)))
     27   (test-equal
     28       "((1 2 3) (4 5 6))"
     29     (format #f "~a" (list x y)))
     30   (test-end "2.26"))