Changeset 37979 in project


Ignore:
Timestamp:
11/07/19 17:54:15 (9 days ago)
Author:
juergen
Message:

holes version 1.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/holes

    r36321 r37979  
    88
    99Besides the documentation procedure, this module exports two curry
    10 procedures, @> and @<, one macro, @@, and a sharp-read-macro, ##, which
    11 abbreviates the call of that latter macro. They all create partial
    12 procedures.
     10procedures, @> and @<, one macro, @@, and a sharp-read-macro, ##, as
     11well as a read-macro, ^, which abbreviates the call of that latter
     12macro. They all create partial procedures.
    1313
    14 The macro transforms expressions with zero or more holes into a
    15 procedure. Insofar, it's a bit like cut or cute. But while in cut or
    16 cute a hole is the special identifier <>, in this module it's a pair of
    17 bangs, possibly enclosing a sequence of digits, for examples !! or !1!.
    18 In this way, holes needn't name different variables like in cut or cute.
     14Holes are spezial identifiers, enclosing zero or more digits either by <
     15and >, the new way, or by bangs !!, the old way.  You can choose between
     16the two versions with a parameter named hole-delimiters.
    1917
    20 Another difference to cut or cute is, that the holes may appear in
    21 nested expressions at different levels. This gives great flexibility.
    22 And the sharp-read-syntax ## adds ease of use.
     18The macro @@ transforms expressions with zero or more holes into a
     19procedure which has as many arguments as there are different holes in
     20the expression. Moreover, the arguments are ordered according to the
     21digits enclosed by the delimiters.
     22
     23For example, (@@ 5), ##5 or ^5, which are all the same, is a thunk,
     24because there are no holes. And ^(- <2> <1> <2>) is a procedure of two
     25arguments, <1> and <2> in this order, returning (- 20 10 20) when
     26applied to 10 20: (^(- <2> <1> <2>) 10 20) is -10.
     27
     28But holes aren't restricted to flat list expressions, nested ones are
     29accepted as well. For example, ^(+ 5 (* <> 2)) is a unary procedure
     30which applied to 7 gives 19. The holes may appear in different
     31nesting levels, which gives great flexibility.
     32
     33Notice the difference of @@ to cut and cute, where two pairs <> <> accept
     34different arguments, @@ would accept only one.
    2335
    2436=== Documentation
     
    2638==== holes
    2739
    28 <procedure>(holes)</procedure>
     40<procedure>(holes [sym])</procedure>
    2941
    30 shows the definition of the @@ macro.
     42documentation procedure. Shows either the list of exported symbols or
     43the documentation of sym.
     44
     45==== hole-delimiters
     46
     47<parameter>(hole-delimiters [str])</parameter>
     48
     49returns or sets the hole-delimiters to either "<>", the default, or
     50"!!".
    3151
    3252==== @@
     
    5979
    6080<enscript highlight=scheme>
     81
     82(hole-delimiters "!!")
     83
    6184((@> map add1) '(0 1 2)) ; -> '(1 2 3)
    6285((@< list-ref 2) '(0 1 2 3)) ; -> 2
     
    100123== Last update
    101124
    102 Aug 18, 2018
     125Nov 07, 2019
    103126
    104127== Author
     
    108131== License
    109132
    110  Copyright (c) 2016-2018, Juergen Lorenz
     133 Copyright (c) 2016-2019, Juergen Lorenz
    111134 All rights reserved.
    112135
     
    138161
    139162== Version History
     163; 1.1 : parameter hole-delimiters added accepting "<>" or "!!"
    140164; 1.0 : port from chicken-4, version 1.4,  with modifications
    141165
    142 
    143 
Note: See TracChangeset for help on using the changeset viewer.