Changeset 34338 in project


Ignore:
Timestamp:
08/24/17 18:04:10 (4 weeks ago)
Author:
kon
Message:

rel 2.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/amb

    r34139 r34338  
    1414the handling of continuations.
    1515
    16 Installs the ''amb'' and ''amb-extras'' extensions.
     16Installs the ''amb'', and the ''amb-extras'' extension, plus examples.
     17
     18=== Usage
     19
     20<enscript language=scheme>
     21(require-library amb)
     22...
     23(import amb)
     24</enscript>
     25
     26or
     27
     28<enscript language=scheme>
     29(require-extension amb)
     30</enscript>
    1731
    1832=== amb-random-function
     
    5266=== amb
    5367
    54 <macro>(amb EXPRESSION...) => TOP</macro>
     68<syntax>(amb EXPRESSION...) => TOP</syntax>
    5569
    5670If the {{EXPRESSION}} has any parameters, the first one of them is evaluated
     
    6478=== amb/random
    6579
    66 <macro>(amb/random EXPRESSION...) => TOP</macro>
     80<syntax>(amb/random EXPRESSION...) => TOP</syntax>
    6781
    6882Works like {{amb}} but the parameters are not selected in sequence but
     
    7185=== amb-find
    7286
    73 <macro>(amb-find EXPRESSION [FAILURE-VALUE]) => *</macro>
     87<syntax>(amb-find EXPRESSION [FAILURE-VALUE]) => *</syntax>
    7488
    7589Evaluates {{EXPRESSION}} returning its value if successful (possibly after
     
    8599=== amb-collect
    86100
    87 <macro>(amb-collect EXPRESSION) => list</macro>
     101<syntax>(amb-collect EXPRESSION) => list</syntax>
    88102
    89103Evaluates {{EXPRESSION}} and performs backtracking repeatedly until all possible
     
    92106=== amb-assert
    93107
    94 <macro>(amb-assert OK?)</macro>
     108<syntax>(amb-assert OK?)</syntax>
    95109
    96110Evaluates {{OK?}} and fails if it is {{#f}}.
     
    129143procedure.
    130144
     145==== shuffle
     146
     147<procedure>(shuffle LS RAND) => list</procedure>
     148
     149Returns a new {{list}} from the randomly-shuffled elements of {{LS}}.
     150
     151{{RAND}} is a procedure returning a random {{integer}} in {{[0, N-1]}}.
     152
    131153
    132154=== Extension ''amb-extras''
    133155
    134 === amb1
    135 
    136 <macro>(amb1 LIST) => TOP</macro>
    137 
    138 {{amb}} but with a single list argument.
    139 
    140 === choose
    141 
    142 <macro>(choose LIST) => TOP</macro>
    143 
    144 {{amb/random}} but with a single list argument.
     156==== Usage
     157
     158<enscript language=scheme>
     159(require-library amb-extras)
     160...
     161(import amb-extras)
     162</enscript>
     163
     164or
     165
     166<enscript language=scheme>
     167(require-extension amb-extras)
     168</enscript>
     169
     170==== amb1
     171
     172<syntax>(amb1 LS) => TOP</syntax>
     173
     174{{amb}} but with a single list argument {{LS}}.
     175
     176==== choose
     177
     178<syntax>(choose LS) => TOP</syntax>
     179
     180{{amb/random}} but with a single list argument {{LS}}.
    145181
    146182==== one-of
    147183
    148 <macro>(one-of EXPRESSION) => *</macro>
     184<syntax>(one-of EXPRESSION) => *</syntax>
    149185
    150186{{amb-find}} synonym.
     
    152188==== all-of
    153189
    154 <macro>(all-of EXPRESSION) => list</macro>
     190<syntax>(all-of EXPRESSION) => list</syntax>
    155191
    156192{{amb-collect}} synonym.
    157193
    158 === required
    159 
    160 <macro>(required EXPRESSION)</macro>
     194==== required
     195
     196<syntax>(required EXPRESSION)</syntax>
    161197
    162198{{amb-assert}} synonym.
    163199
    164 === distinct?
    165 
    166 <procedure>(distinct? LIST [=? equal?]) => boolean</procedure>
    167 
    168 Is, using {{=?}} for comparison, {{LIST}} a {{list}} of distinct elements?
    169 
    170 === count-member
    171 
    172 <procedure>(count-member OBJECT LIST [=? equal?]) => integer</procedure>
    173 
    174 Returns, using {{=?}} for comparison, the number of times {{OBJECT}}
    175 referenced in {{LIST}}.
    176 
    177 
    178 == Usage
    179 
    180 <enscript language=scheme>
    181 (require-library amb)
    182 ...
    183 (import amb)
    184 </enscript>
    185 
    186 or
    187 
    188 <enscript language=scheme>
    189 (require-extension amb)
    190 </enscript>
     200==== distinct?
     201
     202<procedure>(distinct? LS [eql? equal?]) => boolean</procedure>
     203
     204Is, using {{eql?}} for comparison, {{LS}} a {{list}} of distinct elements?
     205
     206==== count-member
     207
     208<procedure>(count-member OBJECT LS [eql? equal?]) => integer</procedure>
     209
     210Returns, using {{eql?}} for comparison, the number of times {{OBJECT}}
     211referenced in {{LS}}.
     212
     213==== list-constantly
     214
     215<procedure>(list-constantly LS) => list</procedure>
     216
     217Returns a new list where each element, {{ELT}}, of {{LS}} is represented by
     218{{(constantly ELT)}}.
    191219
    192220
     
    252280
    253281[[check-errors|check-errors]]
    254 [[miscmacros|miscmacros]]
     282[[miscsyntaxs|miscsyntaxs]]
    255283[[condition-utils|condition-utils]]
    256284
     
    266294== Version history
    267295
     296; 2.3.0 : Add {{shuffle}} & {{list-constantly}}.
    268297; 2.2.0 : Add {{amb-thunks-shuffled}} & {{count-member}}.
    269298; 2.1.7 : Use test.
Note: See TracChangeset for help on using the changeset viewer.