reset password
Author Message
rabbott
Posts: 1649
Posted 15:14 Nov 11, 2015 |

Message deleted. See follow-up below.

Last edited by rabbott at 20:26 Nov 11, 2015.
rabbott
Posts: 1649
Posted 20:18 Nov 11, 2015 |

A number of people in the class have been struggling with computing the effect of any ball on any ball. Here's a starting point. 

;; List all interactions among the balls in the form of a list for each ball.
(define (all-effects all-balls)
  
  ; List the effects of all the balls in all-balls on the ball ball
  (define (effects-on ball)
    (list ball
          (map             ; Replace the format expression with a function that finds an effect
            (lambda (a-ball)(format "~a effect on ~a" a-ball ball))
            all-balls)))
  
  (map effects-on all-balls))

When run:

> (all-effects '(a b c d))
'((a ("a effect on a" "b effect on a" "c effect on a" "d effect on a"))
  (b ("a effect on b" "b effect on b" "c effect on b" "d effect on b"))
  (c ("a effect on c" "b effect on c" "c effect on c" "d effect on c"))
  (d ("a effect on d" "b effect on d" "c effect on d" "d effect on d")))

This has been copied to the wiki.

Last edited by rabbott at 20:27 Nov 11, 2015.