cons-stream. Paste
the following at the top of the definition window to
make this primitive available.
(require (lib "defmacro.ss")) ; cons-stream : obj stream -> stream ; construct a stream whose first element is obj and whose tail is stream ; [cons-stream is a special form] (define-macro cons-stream (lambda (car cdr) `(cons ,car (delay ,cdr))))
amb.
Insert the following at the top of the definition window.
(require (lib "defmacro.ss")) (define amb-fail '*) (define initialize-amb-fail (lambda () (set! amb-fail (lambda () (error "amb tree exhausted"))))) (initialize-amb-fail) (define-macro amb (lambda alts... `(let ((+prev-amb-fail amb-fail)) (call/cc (lambda (+sk) ,@(map (lambda (alt) `(call/cc (lambda (+fk) (set! amb-fail (lambda () (set! amb-fail +prev-amb-fail) (+fk 'fail))) (+sk ,alt)))) alts...) (+prev-amb-fail))))))
07:58:14 <soegaard> You were asking about the picture language in SICP, right? 07:58:38 <jim> soegaard: yes 07:58:58 <soegaard> Mike Sperber implemented it for PLT Scheme. 07:59:18 <jim> cool :) 07:59:45 <soegaard> In DrScheme go to the file menu, and choose "Install .plt file" 08:00:07 <soegaard> Then enter 08:00:08 <soegaard> http://www-pu.informatik.uni-tuebingen.de/users/sperber/software/picture.plt 08:06:33 <soegaard> jim: I am looking for documentation to start it, it must be there somewhere 08:13:45 <soegaard> ah! 08:14:22 <soegaard> jim: In the "Language" menu choose "Add TeachPack". 08:15:24 <soegaard> jim: Then choose the file picture.ss hidden in the TeachPack directory (on my machine: C:/documents and settings/js/Application Date/PLT 208.1/teachpack/picture.ss 08:15:38 <soegaard> jim: Press "Go" 08:15:56 <soegaard> jim: Then try: (paint (corner-split einstein 1)) 08:16:30 <jim> soegaard: trying to find the teachpack (I installed the file as root in linux) 08:31:19 <soegaard> jim: And (paint (corner-split einstein 1)) works? 08:32:51 <jim> we're getting there. it knows paint but not corner-split 08:33:19 <jim> hah! it works 08:33:28 <soegaard> jim: ah! I loaded one of the example files first 08:33:32 <jim> (paint einstein) 08:34:08 <soegaard> jim: I loaded example.scm first and corner-split is defined there. 08:34:50 <jim> are there stick figures? 08:36:01 <soegaard> jim: Open the file collects/painters.ss and see all the provided procedures. 08:36:14 <jim> ahh 08:36:21 <soegaard> jim: There is a segments->painter which can be used to make stick figures. 08:37:45 <jim> soegaard: ok, good enough... now how can I make the imagelarger? 08:38:00 <soegaard> use paint-hi-res 08:39:41 <jim> soegaard: -very- good :) thank you very much :) 08:39:51 <soegaard> no problem
amb -macro was taken from "Teach Yourself Scheme in a Fixnum of Days"
by Dorai Sitaram. This book is integrated in DrScheme - to read it open the
HelpDesk, click at manuals, then click at its title.
| CookbookForm | |
|---|---|
| TopicType: | Other |
| ParentTopic: | |
| TopicOrder: | 999 |