trying to trace why apply isn't working with regards to a simple definition

This commit is contained in:
Danny Yoo 2011-07-28 16:39:21 -04:00
parent a3c9b7c732
commit c7dd5cc99c
2 changed files with 47 additions and 4 deletions

View File

@ -1,7 +1,46 @@
#lang planet dyoo/whalesong
(apply + 2 3 4 5 '())
(apply + 2 3 4 '(5))
(apply + 2 3 '(4 5))
(apply + 2 '(3 4 5))
(apply + '(2 3 4 5))
(apply * 2 3 4 5 '())
(apply * 2 3 4 '(5))
(apply * 2 3 '(4 5))
(apply * 2 '(3 4 5))
(apply * '(2 3 4 5))
(apply (lambda args args) 2 3 4 5 '())
(apply (lambda args args) 2 3 4 '(5))
(apply (lambda args args) 2 3 '(4 5))
(apply (lambda args args) 2 '(3 4 5))
(apply (lambda args args) '(2 3 4 5))
(apply (lambda (a b c) (+ a (* b c))) 2 3 '(4))
(add1 (apply (lambda (a b c) (+ a (* b c))) 2 3 '(4)))
(= (apply (lambda (a b c) (+ a (* b c))) 2 3 '(4))
0)
(apply list 3 4 '(5))
(define (square x)
(* x x))
(apply square '(7))
"squaring"
(define (square2 x)
(apply * (list x x)))
(apply square2 '(7))
(apply square2 8 '())
"now factorial"
@ -12,6 +51,10 @@
[else
(apply * `(,x ,(apply f (apply sub1 (apply list x '())) '())))]))
(f 3)
(+ (f 4) (f 5))
(f 0)
;(f 1)
;(f 2)
;(f 3)
;(f 4)
;(f 5)
;(+ (f 4) (f 5))

View File

@ -17,4 +17,4 @@
(test "more-tests/lists.rkt")
(test "more-tests/earley.rkt")
(test "more-tests/hello-bf.rkt")
(test "more-tests/simple-apply.rkt")
#;(test "more-tests/simple-apply.rkt")