]> gitweb.factorcode.org Git - factor.git/blob - extra/lists/lists-docs.factor
Renaming map-cons to lmap and lmap to lazy-map
[factor.git] / extra / lists / lists-docs.factor
1 ! Copyright (C) 2006 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax ;
4
5 IN: lists
6
7 { car cons cdr nil nil? list? uncons } related-words
8
9 HELP: cons 
10 { $values { "car" "the head of the lazy list" } { "cdr" "the tail of the lazy list" } { "cons" "a cons object" } }
11 { $description "Constructs a cons cell." } ;
12
13 HELP: car
14 { $values { "cons" "a cons object" } { "car" "the first item in the list" } }
15 { $description "Returns the first item in the list." } ;
16
17 HELP: cdr
18 { $values { "cons" "a cons object" } { "cdr" "a cons object" } }
19 { $description "Returns the tail of the list." } ;
20
21 HELP: nil 
22 { $values { "cons" "An empty cons" } }
23 { $description "Returns a representation of an empty list" } ;
24
25 HELP: nil? 
26 { $values { "cons" "a cons object" } { "?" "a boolean" } }
27 { $description "Return true if the cons object is the nil cons." } ;
28
29 HELP: list? ( object -- ? )
30 { $values { "object" "an object" } { "?" "a boolean" } }
31 { $description "Returns true if the object conforms to the list protocol." } ;
32
33 { 1list 2list 3list } related-words
34
35 HELP: 1list
36 { $values { "obj" "an object" } { "cons" "a cons object" } }
37 { $description "Create a list with 1 element." } ;
38
39 HELP: 2list
40 { $values { "a" "an object" } { "b" "an object" } { "cons" "a cons object" } }
41 { $description "Create a list with 2 elements." } ;
42
43 HELP: 3list
44 { $values { "a" "an object" } { "b" "an object" } { "c" "an object" } { "cons" "a cons object" } }
45 { $description "Create a list with 3 elements." } ;
46     
47 HELP: lnth
48 { $values { "n" "an integer index" } { "list" "a cons object" } { "elt" "the element at the nth index" } }
49 { $description "Outputs the nth element of the list." } 
50 { $see-also llength cons car cdr } ;
51
52 HELP: llength
53 { $values { "list" "a cons object" } { "n" "a non-negative integer" } }
54 { $description "Outputs the length of the list. This should not be called on an infinite list." } 
55 { $see-also lnth cons car cdr } ;
56
57 HELP: uncons
58 { $values { "cons" "a cons object" } { "car" "the head of the list" } { "cdr" "the tail of the list" } }
59 { $description "Put the head and tail of the list on the stack." } ;
60
61 HELP: leach
62 { $values { "list" "a cons object" } { "quot" "a quotation with stack effect ( obj -- )" } }
63 { $description "Call the quotation for each item in the list." } ;
64
65 HELP: lreduce
66 { $values { "list" "a cons object" } { "identity" "an object" } { "quot" "a quotation with stack effect ( prev elt -- next )" } { "result" "the final result" } }
67 { $description "Combines successive elements of the list using a binary operation, and outputs the final result." } ;