Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg]] == sequences utils [[toc:]] (MoreO perations over generic or user-defined sequences. == Documentation Import all modules: === Usage <enscript language=scheme> (import (sequences utils)) ;but suggest (import (prefix (sequences utils) seq:)) </enscript> === Types ==== sequence ==== binary-predicate <type>sequence : (or string vector list ...)</type> <type>binary-predicate : ('a 'a -> boolean)</type> '''Note''' a {{sequence}} as understood by the {{sequences}} egg. === (sequences utils misc) ==== Usage <enscript language=scheme> (import (sequences utils misc)) ;but suggest (import (prefix (sequences utils misc) seq:)) </enscript> ==== ->list ==== ->vector ==== ->string <procedure>(->list SEQ) -> list</procedure> <procedure>(->vector SEQ) -> vector</procedure> <procedure>(->string SEQ) -> string</procedure> Coerce {{SEQ}} to the named {{sequence}} type, unless an instance. ; {{SEQ}} : {{sequence}} ; sequence to coerce. ==== reduce <procedure>(reduce F SEED SEQ) -> sequence</procedure> ; {{SEQ}} : {{sequence}} ; sequence to reduce. ; {{F}} : {{('a 'a -> 'a)}} ; ; {{SEED}} : {{'a}} ; initial value. ; {{=?}} : {{binary-predicate}} ; equality predicate, default is {{equal?}}. ==== foldl->alist <procedure>(foldl->alist SEQ FUNC SEED [EQAL?]) -> alist</procedure> Returns the {{RESULT}} {{alist}} from the left fold of the {{SEQ}}. ; {{SEQ}} : {{sequence}} ; sequence to fold over. ; {{FUNC}} : {{('a * -> 'a)}} ; update value function. ; {{SEED}} : {{'a}} ; initial value. ; {{EQAL?}} : {{(* * -> boolean)}} ; equality predicate; default {{equal?}}. ; {{RESULT}} : {{{(list-of (pair * 'a))}}} ; key'ed by unique values from {{SEQ}}. === (sequences utils sort) ==== Usage <enscript language=scheme> (import (sequences utils sort)) ;but suggest (import (prefix (sequences utils sort) seq:)) </enscript> ==== merge! <procedure>(merge! SEQ-A SEQ-B <?) -> sequence</procedure> Attempts to merge {{SEQ-B}} into {{SEQ-A}}, but will return a merged sequence. ; {{SEQ-A SEQ-B}} : {{sequence sequence}} ; sequences to merge. ; {{<?}} : {{binary-predicate}} ; less-than predicate. Return {{sequence}} is coerced to the same type as {{SEQA}}. ==== merge <procedure>(merge SEQ-A SEQ-B <?) -> sequence</procedure> ; {{SEQ-A SEQ-B}} : {{sequence sequence}} ; sequences to merge. ; {{<?}} : {{binary-predicate}} ; less-than predicate. Return {{sequence}} is coerced to the same type as {{SEQA}}. ==== sorted? <procedure>(sorted? SEQ <?) -> boolean</procedure> ; {{SEQ}} : {{sequence}} ; sequence to test. ; {{<?}} : {{binary-predicate}} ; less-than predicate. ==== sort! <procedure>(sort! SEQ <?) -> sequence</procedure> Attempts to sort the {{SEQ}} in place, but will return a sorted sequence. ; {{SEQ}} : {{sequence}} ; sequence to sort. ; {{<?}} : {{binary-predicate}} ; less-than predicate. Return {{sequence}} is coerced to the same type as {{SEQ}}. ==== sort <procedure>(sort SEQ <?) -> sequence</procedure> ; {{SEQ}} : {{sequence}} ; sequence to sort. ; {{<?}} : {{binary-predicate}} ; less-than predicate. Return {{sequence}} is coerced to the same type as {{SEQ}}. ==== unique <procedure>(unique SEQ [=?]) -> sequence</procedure> Remove duplicates in sorted sequence {{SEQ}}, equality determined by {{=?}}. ; {{SEQ}} : {{sequence}} ; sorted sequence. ; {{=?}} : {{binary-predicate}} ; equal predicate. Return {{sequence}} is same type as {{SEQ}}. ==== unique/unsorted <procedure>(unique/unsorted SEQ) -> sequence</procedure> Remove duplicates in the, possibly unsorted, sequence {{SEQ}}. ; {{SEQ}} : {{sequence}} ; sequence to unique. Return {{sequence}} is same type as {{SEQ}}. === (sequences utils sample) ==== Usage <enscript language=scheme> (import (sequences utils sample)) ;but suggest (import (prefix (sequences utils sample) seq:)) </enscript> ==== histogram <procedure>(histogram SEQ [=?]) -> alist</procedure> Returns an {{(list-of ('a . integer))}} where {{SEQ}} is {{(sequence-of 'a)}}. ; {{SEQ}} : {{sequence}} ; sequence to count element by element. ; {{=?}} : {{binary-predicate}} ; equality predicate, default is {{equal?}}. ==== random-integers <procedure>(random-integers SEQ CNT [END [LOW [DUPS?]]]) -> sequence</procedure> Returns a {{SEQ}}, of random integers, with elements in the integer range {{[LOW END)}}. ; {{SEQ}} : {{sequence}} ; sequence to emulate. ; {{CNT}} : {{fixnum}} ; number of elements. ; {{END}} : {{integer}} ; maximum value limit, default is {{most-positive-fixnum}}. ; {{LOW}} : {{integer}} ; minimum value, default is {{0}}. ; {{DUPS?}} : {{boolean}} ; allow duplicates, default is {{#f}}. * Should abstract random source & random element type ==== random-reals <procedure>(random-reals SEQ CNT [DUPS?]) -> sequence</procedure> Returns a {{SEQ}}, of {{CNT}} random floats. ; {{SEQ}} : {{sequence}} ; sequence to emulate. ; {{CNT}} : {{fixnum}} ; number of elements. ; {{DUPS?}} : {{boolean}} ; allow duplicates, default is {{#f}}. ==== random-sample <procedure>(random-sample SEQ [CNT]) -> sequence</procedure> Returns list of elements randomly sampled from {{SEQ}}. ; {{SEQ}} : {{sequence}} ; sequence to sample. ; {{CNT}} : {{fixnum}} ; length of result list, default is random in {{[0 (- (size SEQ) 1)]}}. ==== cyclic-sample <procedure>(cyclic-sample SEQ [CNT]) -> sequence</procedure> Returns a sequence with elements sampled every {{CNT}} from {{SEQ}}. ; {{SEQ}} : {{sequence}} ; sequence to sample. ; {{CNT}} : {{fixnum}} ; cycle length, default is {{7}}. Return {{sequence}} is same type as {{SEQ}}. == Requirements [[srfi-1]] [[srfi-69]] [[sequences]] [[test]] [[test-utils]] == Authors [[/users/kon-lovett|Kon Lovett]] == Repository This egg is hosted on the CHICKEN Subversion repository: [[https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/sequences-utils|https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/sequences-utils]] If you want to check out the source code repository of this egg and you are not familiar with Subversion, see [[/egg-svn-checkout|this page]]. == Version history ; 0.5.1 : Fix {{reduce}}. Fix {{random-reals}} type. ; 0.5.0 : Split into separate submodules. ; 0.4.0 : Add {{reduce}}. New test-runner. ; 0.3.1 : Add {{unique/unsorted}} type. ; 0.3.0 : Fix types. Added {{unique/unsorted}}. ; 0.2.1 : Fix types. Added {{randoms}} {{DUPS?}} argument. ; 0.2.0 : Added {{unique}}. {{randoms}}, and {{sample}}. ; 0.1.1 : Fix types. ; 0.1.0 : C5 release. Originally {{seq-utils}} from {{micro-stats}}. == License Copyright (c) 2022-2023, Kon Lovett All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 0 by 1?