Changeset 38850 in project
 Timestamp:
 08/17/20 10:53:08 (6 weeks ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

wiki/eggref/5/callablesequences
r38845 r38850 5 5 6 6 This is a variant of Mario's callabledatastructures. But contrary to 7 that egg, I don't consider hashtables, but only ordered sequences, 8 presently lists, pseudolists, vectors and strings. Additionally, there are two 9 constructors for handling arbitrary sequential and randomaccess 10 sequences. Of course both types are implemented differently. 11 12 Since those sequences are ordered, it makes sense to consider not only 13 references but slices as well. So, for example, if vec is (makecallable 14 #(0 1 2 3 4 5)), then (vec 1 4) or (vec 4 1) are callables comprising 15 #(1 2 3) or #(4 3 2) respectively. Note, that the left index is always 16 included, while the right one is excluded. 17 18 For ease of use, one of the two arguments of slices can be #f. This 19 argument then represents the sequence's length in (vec 1 #f) or its 20 length minus one in (vec #f 3). 7 that egg, I don't consider hashtables, but only ordered sequences. 8 9 The most important procedure, makecallable, is a generic procedure with 10 a local database supporting lists, pseudolists, vectors and strings. But 11 this database can be enhanced, by giving makecallable two unary 12 procedures as arguments, a type predicate and a maker, the latter being 13 a spezialization of makesascallable or makerascallable, handling 14 sequentialaccess or randomaccess sequences respectively. 15 16 Giving makecallable one argument, a sequence, a procedure of zero, one 17 or two arguments is returned. The first call returns the encapsulated data 18 and its length, the second the data's value at its index argument and 19 the third the slice between its two index arguments, in either 20 direction, the first included, the second excluded. For convenience, the 21 argument #f is allowed in slices, representing the length. 22 23 So, for example, if vec is (makecallable #(0 1 2 3 4 5)), then 24 (vec 1 4) or (vec 4 1) are callables comprising #(1 2 3) or #(4 3 2) 25 respectively, and, using length, (vec 3 #f) or (vec #f 3) comprise 26 #(3 4 5) or #(5 4) respectively. 21 27 22 28 === API … … 32 38 ==== makecallable 33 39 40 <procedure>(makecallable)</procedure> 34 41 <procedure>(makecallable seq)</procedure> 35 36 constructor: transforms the sequence into a procedure of zero, one or 37 two arguments. 42 <procedure>(makecallable seq? seqmaker?)</procedure> 43 44 generic procedure. 45 46 The first resets the local datbase to standard form, which can handle 47 lists, vectors, strings and pseudolists. 48 49 The second transforms the sequence into a procedure of zero, one or 50 two arguments, meaning 38 51 39 52 * zero: returns the original sequence and its length … … 41 54 * two: returns the slice of its integer arguments respecting their order 42 55 56 The third updates the local database inserting the new pair in next to 57 last position. The seqmaker argument specializes one of the two 58 constructors makesascallable and makerascallable respectively. 59 43 60 ==== makesascallable 44 61 … … 185 202 == Last update 186 203 187 Aug 1 4, 2020204 Aug 17, 2020 188 205 189 206 == Author … … 223 240 224 241 == Version History 225 ; 1.0 ; initial version242 ; 1.0.0 ; initial version
Note: See TracChangeset
for help on using the changeset viewer.