Changeset 20948 in project


Ignore:
Timestamp:
10/23/10 04:21:48 (8 years ago)
Author:
kon
Message:

Rel 1.1.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/list-utils

    r19761 r20948  
    1010== Documentation
    1111
    12 ==== length=0?
     12=== skip+
     13
     14<procedure>(skip+ LIST COUNT) => (list integer)</procedure>
     15
     16Returns 2 values, the {{COUNT}} {{pair}} from {{LIST}}, and the remaining
     17count. The remaining count will be non-zero when end-of-list reached.
     18
     19{{COUNT}} is a {{natural fixnum}}.
     20
     21<enscript language=scheme>
     22(skip+ '(1 2) 3) ;=> '() 1
     23(skip+ '(1 2 3) 3) ;=> '() 0
     24(skip+ '(1 2 3 4) 3) ;=> '(4) 0
     25</enscript>
     26
     27=== split-at+
     28
     29<procedure>(split-at+ LIST COUNT [PADS]) => (list list)</procedure>
     30
     31Returns 2 values, the leading {{COUNT}} elements from {{LIST}} as a new
     32{{list}}, and the remaining elements from {{LIST}}. Should there be fewer than
     33{{COUNT}} elements available padding is attempted.
     34
     35Padding is performed by trying to complete the remaining elements from the {{list}}
     36{{PADS}}.
     37
     38{{COUNT}} is a {{natural fixnum}}.
     39{{PADS}} is a {{list}} or {{#f}}. Default is {{'()}}.
     40
     41A negative {{COUNT}} is treated as {{0}}.
     42
     43When {{PADS}} is {{#f}} then an incomplete leading sublist is treated as
     44{{'()}}. The very odd treatment of {{PADS}} = {{#f}} can safely be ignored
     45since this is not the default behavior.
     46
     47<enscript language=scheme>
     48(split-at+ '(1 2 3) 3) ;=> '(1 2 3) '()
     49(split-at+ '(1 2 3) 2) ;=> '(1 2) '(3)
     50(split-at+ '(1 2 3) 4) ;=> '(1 2 3) '()
     51(split-at+ '(1 2 3) 4 #f) ;=> '() '()
     52</enscript>
     53
     54=== section
     55
     56<procedure>(section LIST SIZE [[STEP] PADS]) => list</procedure>
     57
     58Returns a {{list}} of {{list}}, built by taking {{SIZE}} elements from
     59{{LIST}} every {{STEP}} elements. When too few elements remain to complete a
     60''section'' padding is performed.
     61
     62{{SIZE}} is a {{positive fixnum}}.
     63{{STEP}} is a {{positive fixnum}}. Default is {{SIZE}}.
     64{{PADS}} is a {{list}} or {{#f}}. Default is {{'()}}.
     65
     66When {{PADS}} is {{#f}} then any incomplete trailing section is dropped. The
     67very odd treatment of {{PADS}} = {{#f}} can safely be ignored since this is not
     68the default behavior.
     69
     70<enscript language=scheme>
     71(section '(1 2) 3 3 '(3 4 5)) ;=> ((1 2 3))
     72(section '(1 2 3) 2 1 '(3 4 5)) ;=> ((1 2) (2 3))
     73(section '(1 2 3) 2 2 '(4 5)) ;=> ((1 2) (3 4))
     74(section '(1 2 3) 2 2) ;=> ((1 2) (3))
     75</enscript>
     76
     77=== length=0?
    1378
    1479<macro>(length=0? LIST) => boolean</macro>
     
    1681List of length zero? (Just {{null?}}.)
    1782
    18 ==== length=1?
     83=== length=1?
    1984
    2085<macro>(length=1? LIST) => boolean</macro>
     
    2287List of length one?
    2388
    24 ==== length>1?
     89=== length>1?
    2590
    2691<macro>(length>1? LIST) => boolean</macro>
     
    2893List of length greater than one?
    2994
    30 ==== length=2?
     95=== length=2?
    3196
    3297<macro>(length=2? LIST) => boolean</macro>
     
    3499List of length two?
    35100
    36 ==== ensure-list
     101=== ensure-list
    37102
    38103<macro>(ensure-list OBJECT) => list</macro>
     
    40105Returns a list, either the list {{OBJECT}} or {{(list OBJECT)}}.
    41106
    42 ==== not-null?
    43 
    44 <macro>(not-null? LIST) => (union list boolean)</macro>
     107=== not-null?
     108
     109<macro>(not-null? LIST) => (or list boolean)</macro>
    45110
    46111Returns {{#f}} if the given {{LIST}} is empty, and {{LIST}} otherwise.
    47112
    48 ==== alist-delete-first
     113=== alist-delete-first
    49114
    50115<macro>(alist-delete-first KEY ALIST [TEST?])</macro>
     
    52117Returns {{(alist-delete/count KEY ALIST [TEST?] 1)}}.
    53118
    54 ==== alist-delete-first!
     119=== alist-delete-first!
    55120
    56121<macro>(alist-delete-first! KEY ALIST [TEST?])</macro>
     
    58123Destructive version of {{alist-delete-first}}.
    59124
    60 ==== assoc-def
     125=== assoc-def
    61126
    62127<macro>(assoc-def KEY ALIST [TEST] [NOT-FOUND])</macro>
     
    64129The assoc procedure with an optional test and default value.
    65130
    66 ==== assv-def
     131=== assv-def
    67132
    68133<macro>(assv-def KEY ALIST [NOT-FOUND])</macro>
     
    70135The assv procedure with a default value.
    71136
    72 ==== assq-def
     137=== assq-def
    73138
    74139<macro>(assq-def KEY ALIST [NOT-FOUND])</macro>
     
    76141The assq procedure with a default value.
    77142
    78 ==== alist-inverse-ref
     143=== alist-inverse-ref
    79144
    80145<procedure>(alist-inverse-ref VALUE ALIST [TEST? [NOT-FOUND]])</procedure>
     
    85150{{TEST?}} is {{eqv?}} and {{NOT-FOUND}} is {{#f}}.
    86151
    87 ==== alist-delete/count
     152=== alist-delete/count
    88153
    89154<procedure>(alist-delete/count KEY ALIST [TEST? [COUNT]])</procedure>
     
    104169{{eqv?}}.
    105170
    106 ==== alist-delete!/count
     171=== alist-delete!/count
    107172
    108173<procedure>(alist-delete!/count KEY ALIST [TEST? [COUNT]])</procedure>
     
    113178procedures.
    114179
    115 ==== unzip-alist
     180=== unzip-alist
    116181
    117182<procedure>(unzip-alist ALIST)</procedure>
     
    119184Returns 2 values, a list of the keys & a list of the values from the {{ALIST}}.
    120185
    121 ==== zip-alist
     186=== zip-alist
    122187
    123188<procedure>(zip-alist KEYS VALUES)</procedure>
     
    130195invoked.
    131196
    132 ==== plist->alist
     197=== plist->alist
    133198
    134199<procedure>(plist->alist PLIST) => list</procedure>
     
    136201Returns the association-list form of {{PLIST}}.
    137202
    138 ==== alist->plist
     203=== alist->plist
    139204
    140205<procedure>(alist->plist ALIST) => list</procedure>
     
    142207Returns the property-list form of {{ALIST}}.
    143208
    144 ==== shift!
     209=== shift!
    145210
    146211<procedure>(shift! LIST [DEFAULT]) => *</procedure>
     
    153218Like a stack-pop.
    154219
    155 ==== unshift!
     220=== unshift!
    156221
    157222<procedure>(unshift! OBJECT LIST) => list</procedure>
     
    162227Like a stack-push.
    163228
    164 ==== shift!/set
     229=== shift!/set
    165230
    166231<macro>(shift!/set VARIABLE [WHEN-EMPTY])</macro>
     
    172237{{VARIABLE}} is empty.
    173238
    174 ==== andmap
     239=== andmap
    175240
    176241<procedure>(andmap FUNC LIST...) => boolean</procedure>
     
    180245{{(and (FUNC (car LIST)...) (andmap FUNC (cdr LIST)...))}}.
    181246
    182 ==== ormap
     247=== ormap
    183248
    184249<procedure>(ormap FUNC LIST...) => boolean</procedure>
     
    211276== Version history
    212277
    213 ; 1.0.0 :
     278; 1.1.0 : Added {{skip+}}, {{split-at+}}, and {{section}}.
     279; 1.0.0 : Hello,
    214280
    215281
Note: See TracChangeset for help on using the changeset viewer.