Changeset 32536 in project


Ignore:
Timestamp:
07/04/15 02:37:44 (5 years ago)
Author:
Peter Danenberg
Message:

sicp: Update docs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/sicp

    r32436 r32536  
    44[[toc:]]
    55=== SICP
     6==== {{sicp}}
     7'''[module]''' {{sicp}}
     8
    69SICP is a grab-bag of different procedures from sections 1
    710through 3.3.4, before we started modularizing them (starting from
    8113.3.5: Constraints).
    9 
    10 
    11 ==== {{sicp}}
    12 '''[module]''' {{sicp}}
    13 
    14 Evaluates {{expressions}} and returns the time required for
    15 evaluation plus the return values of evaluating {{expressions}}.
    1612* [[#=number?]]
    1713* [[#accumulate]]
     
    965961    (lambda () failure)))
    966962</enscript>
    967 ==== {{ambeval*}}
    968 <procedure>(ambeval* exp env) → object</procedure>
    969 Amb-evaluates the expression until failure, returning the last
    970 success-value; or failure, if it never succeeds.
    971 ; {{exp}} : The expression to evaluate
    972 ; {{env}} : The environment to evaluate it in
    973 <enscript highlight="scheme">(define (ambeval* exp env)
    974   (let ((last-value failure))
    975     (ambeval
    976       exp
    977       env
    978       (lambda (val next-alternative) (set! last-value val) (next-alternative))
    979       (lambda () last-value))))
    980 </enscript>
    981963==== {{ambeval-fold}}
    982964<procedure>(ambeval-fold exp env cons nil) → list</procedure>
     
    10411023==== {{with-require}}
    10421024<procedure>(with-require procedures receive-env) → object</procedure>
    1043 Installs {{require}},{{an-element-of}},{{an-integer-starting-from}}
     1025Installs {{require}}, {{an-element-of}}, {{an-integer-starting-from}}
    10441026in the environment in addition to the primitive procedures enumerated
    10451027in {{procedures}}; then calls {{receive-env}} with the configured environment.
     
    10481030<enscript highlight="scheme">(define (with-require procedures receive-env)
    10491031  (with-primitive-procedures
    1050     (append procedures `((not ,not)))
     1032    (append procedures `((member ,member) (not ,not)))
    10511033    (lambda (env)
    10521034      (ambeval* '(define (require p) (if (not p) (amb) 'success)) env)
     
    10601042           (amb n (an-integer-starting-from (+ n 1))))
    10611043        env)
     1044      (ambeval*
     1045        '(define (distinct? items)
     1046           (cond ((null? items) true)
     1047                 ((null? (cdr items)) true)
     1048                 ((member (car items) (cdr items)) false)
     1049                 (else (distinct? (cdr items)))))
     1050        env)
    10621051      (receive-env env))))
    10631052</enscript>
     
    10721061BSD
    10731062==== Dependencies
     1063* [[debug]]
    10741064* [[hahn]]
    10751065* [[htmlprag]]
     
    10921082; [[https://github.com/klutometis/sicp-chicken/releases/tag/0.1.6|0.1.6]] : Add `prime?'.
    10931083; [[https://github.com/klutometis/sicp-chicken/releases/tag/0.2|0.2]] : Add picture language.
     1084; [[https://github.com/klutometis/sicp-chicken/releases/tag/0.2.12|0.2.12]] : Add ambeval-fold, ambeval-map; change ambeval*.
     1085; [[https://github.com/klutometis/sicp-chicken/releases/tag/0.2.13|0.2.13]] : Remove redundant ambeval*.
    10941086; [[https://github.com/klutometis/sicp-chicken/releases/tag/0.3|0.3]] : Add the outline-painter.
    10951087; [[https://github.com/klutometis/sicp-chicken/releases/tag/0.4|0.4]] : Add differentation.
     
    11341126; [[https://github.com/klutometis/sicp-chicken/releases/tag/0.12|0.12]] : Add the amb-evaluator.
    11351127; [[https://github.com/klutometis/sicp-chicken/releases/tag/0.12.1|0.12.1]] : Export with-lazy-lists.
     1128; [[https://github.com/klutometis/sicp-chicken/releases/tag/0.12.4|0.12.4]] : Add debug to the dependencies.
     1129; [[https://github.com/klutometis/sicp-chicken/releases/tag/0.12.5|0.12.5]] : Add `distinct?' to amb-eval.
     1130; [[https://github.com/klutometis/sicp-chicken/releases/tag/0.12.6|0.12.6]] : Add member to the list of imported functions.
    11361131==== Colophon
    11371132
Note: See TracChangeset for help on using the changeset viewer.