trying to trace why apply isn't working with regards to a simple definition
This commit is contained in:
parent
a3c9b7c732
commit
c7dd5cc99c
|
@ -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))
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user