prelude 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +25 -1
- data/README +11 -12
- data/Rakefile +6 -10
- data/lib/prelude.rb +36 -91
- data/lib/prelude/{tuple.rb → array_list.rb} +30 -27
- data/lib/prelude/functions.rb +414 -0
- data/lib/prelude/functors.rb +72 -0
- data/lib/prelude/lambda.rb +89 -0
- data/lib/prelude/minimal_array_list.rb +61 -0
- data/lib/prelude/monad.rb +11 -15
- data/lib/prelude/proper_list.rb +47 -0
- data/lib/prelude/proper_ruby_list.rb +48 -0
- data/lib/prelude/util.rb +33 -0
- data/test/tc_functions.rb +801 -0
- data/test/tc_monad.rb +21 -41
- data/test/ts_prelude.rb +2 -8
- metadata +13 -36
- data/doc/classes/Kernel.html +0 -198
- data/doc/classes/Prelude.html +0 -241
- data/doc/classes/Prelude/EmptyListError.html +0 -113
- data/doc/classes/Prelude/List.html +0 -2692
- data/doc/classes/Prelude/MissingFunctionError.html +0 -113
- data/doc/classes/Prelude/Monad.html +0 -283
- data/doc/classes/Prelude/Tuple.html +0 -217
- data/doc/classes/Proc.html +0 -198
- data/doc/classes/Symbol.html +0 -219
- data/doc/created.rid +0 -1
- data/doc/files/CHANGELOG.html +0 -122
- data/doc/files/README.html +0 -328
- data/doc/files/TODO.html +0 -95
- data/doc/files/lib/prelude/list_rb.html +0 -83
- data/doc/files/lib/prelude/monad_rb.html +0 -83
- data/doc/files/lib/prelude/tuple_rb.html +0 -83
- data/doc/files/lib/prelude_rb.html +0 -98
- data/doc/fr_class_index.html +0 -35
- data/doc/fr_file_index.html +0 -33
- data/doc/fr_method_index.html +0 -140
- data/doc/index.html +0 -27
- data/doc/rdoc-style.css +0 -208
- data/lib/prelude/list.rb +0 -588
- data/test/tc_higher.rb +0 -89
- data/test/tc_list.rb +0 -777
- data/test/tc_tuple.rb +0 -82
data/doc/index.html
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
5
|
-
|
6
|
-
<!--
|
7
|
-
|
8
|
-
Prelude -- a Haskell-like library for functional programming
|
9
|
-
|
10
|
-
-->
|
11
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
12
|
-
<head>
|
13
|
-
<title>Prelude -- a Haskell-like library for functional programming</title>
|
14
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
15
|
-
</head>
|
16
|
-
|
17
|
-
<frameset cols="20%,*">
|
18
|
-
<frameset rows="15%,35%,50%">
|
19
|
-
<frame src="fr_file_index.html" title="Files" name="Files">
|
20
|
-
<frame src="fr_class_index.html" name="Classes">
|
21
|
-
<frame src="fr_method_index.html" name="Methods">
|
22
|
-
</frameset>
|
23
|
-
<frameset>
|
24
|
-
<frame src="files/README.html" name="docwin">
|
25
|
-
</frameset>
|
26
|
-
</frameset>
|
27
|
-
</html>
|
data/doc/rdoc-style.css
DELETED
@@ -1,208 +0,0 @@
|
|
1
|
-
|
2
|
-
body {
|
3
|
-
font-family: Verdana,Arial,Helvetica,sans-serif;
|
4
|
-
font-size: 90%;
|
5
|
-
margin: 0;
|
6
|
-
margin-left: 40px;
|
7
|
-
padding: 0;
|
8
|
-
background: #efefef;
|
9
|
-
}
|
10
|
-
|
11
|
-
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
|
12
|
-
h1 { font-size: 150%; }
|
13
|
-
h2,h3,h4 { margin-top: 1em; }
|
14
|
-
|
15
|
-
a { background: #eef; color: #039; text-decoration: none; }
|
16
|
-
a:hover { background: #039; color: #eef; }
|
17
|
-
|
18
|
-
/* Override the base stylesheet's Anchor inside a table cell */
|
19
|
-
td > a {
|
20
|
-
background: transparent;
|
21
|
-
color: #039;
|
22
|
-
text-decoration: none;
|
23
|
-
}
|
24
|
-
|
25
|
-
/* and inside a section title */
|
26
|
-
.section-title > a {
|
27
|
-
background: transparent;
|
28
|
-
color: #eee;
|
29
|
-
text-decoration: none;
|
30
|
-
}
|
31
|
-
|
32
|
-
/* === Structural elements =================================== */
|
33
|
-
|
34
|
-
div#index {
|
35
|
-
margin: 0;
|
36
|
-
margin-left: -40px;
|
37
|
-
padding: 0;
|
38
|
-
font-size: 90%;
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
div#index a {
|
43
|
-
margin-left: 0.7em;
|
44
|
-
}
|
45
|
-
|
46
|
-
div#index .section-bar {
|
47
|
-
margin-left: 0px;
|
48
|
-
padding-left: 0.7em;
|
49
|
-
background: #ccc;
|
50
|
-
font-size: small;
|
51
|
-
}
|
52
|
-
|
53
|
-
|
54
|
-
div#classHeader, div#fileHeader {
|
55
|
-
width: auto;
|
56
|
-
color: white;
|
57
|
-
padding: 0.5em 1.5em 0.5em 1.5em;
|
58
|
-
margin: 0;
|
59
|
-
margin-left: -40px;
|
60
|
-
border-bottom: 3px solid #006;
|
61
|
-
}
|
62
|
-
|
63
|
-
div#classHeader a, div#fileHeader a {
|
64
|
-
background: inherit;
|
65
|
-
color: white;
|
66
|
-
}
|
67
|
-
|
68
|
-
div#classHeader td, div#fileHeader td {
|
69
|
-
background: inherit;
|
70
|
-
color: white;
|
71
|
-
}
|
72
|
-
|
73
|
-
|
74
|
-
div#fileHeader {
|
75
|
-
background: #057;
|
76
|
-
}
|
77
|
-
|
78
|
-
div#classHeader {
|
79
|
-
background: #048;
|
80
|
-
}
|
81
|
-
|
82
|
-
|
83
|
-
.class-name-in-header {
|
84
|
-
font-size: 180%;
|
85
|
-
font-weight: bold;
|
86
|
-
}
|
87
|
-
|
88
|
-
|
89
|
-
div#bodyContent {
|
90
|
-
padding: 0 0 0 0;
|
91
|
-
}
|
92
|
-
|
93
|
-
div#description {
|
94
|
-
padding: 0.5em 0.5em;
|
95
|
-
border: 1px dotted #999;
|
96
|
-
margin-left: -40px;
|
97
|
-
}
|
98
|
-
|
99
|
-
div#description h1,h2,h3,h4,h5,h6 {
|
100
|
-
color: #125;;
|
101
|
-
background: transparent;
|
102
|
-
}
|
103
|
-
|
104
|
-
div#validator-badges {
|
105
|
-
text-align: center;
|
106
|
-
}
|
107
|
-
div#validator-badges img { border: 0; }
|
108
|
-
|
109
|
-
div#copyright {
|
110
|
-
color: #333;
|
111
|
-
background: #efefef;
|
112
|
-
font: 0.75em sans-serif;
|
113
|
-
margin-top: 5em;
|
114
|
-
margin-bottom: 0;
|
115
|
-
padding: 0.5em 2em;
|
116
|
-
}
|
117
|
-
|
118
|
-
|
119
|
-
/* === Classes =================================== */
|
120
|
-
|
121
|
-
table.header-table {
|
122
|
-
color: white;
|
123
|
-
font-size: small;
|
124
|
-
}
|
125
|
-
|
126
|
-
.type-note {
|
127
|
-
font-size: small;
|
128
|
-
color: #DEDEDE;
|
129
|
-
}
|
130
|
-
|
131
|
-
.xxsection-bar {
|
132
|
-
background: #eee;
|
133
|
-
color: #333;
|
134
|
-
padding: 3px;
|
135
|
-
}
|
136
|
-
|
137
|
-
.section-bar {
|
138
|
-
color: #333;
|
139
|
-
border-bottom: 1px solid #999;
|
140
|
-
margin-left: -20px;
|
141
|
-
}
|
142
|
-
|
143
|
-
|
144
|
-
.section-title {
|
145
|
-
background: #79a;
|
146
|
-
color: #eee;
|
147
|
-
padding: 3px;
|
148
|
-
margin-top: 2em;
|
149
|
-
margin-left: -30px;
|
150
|
-
border: 1px solid #999;
|
151
|
-
}
|
152
|
-
|
153
|
-
.top-aligned-row { vertical-align: top }
|
154
|
-
.bottom-aligned-row { vertical-align: bottom }
|
155
|
-
|
156
|
-
/* --- Context section classes ----------------------- */
|
157
|
-
|
158
|
-
.context-row { }
|
159
|
-
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
|
160
|
-
.context-item-value { font-size: small; color: #448; }
|
161
|
-
.context-item-desc { color: #333; padding-left: 2em; }
|
162
|
-
|
163
|
-
/* --- Method classes -------------------------- */
|
164
|
-
.method-detail {
|
165
|
-
background: #efefef;
|
166
|
-
padding: 0;
|
167
|
-
margin-top: 0.5em;
|
168
|
-
margin-bottom: 1em;
|
169
|
-
border: 1px dotted #ccc;
|
170
|
-
}
|
171
|
-
.method-heading {
|
172
|
-
color: black;
|
173
|
-
background: #ccc;
|
174
|
-
border-bottom: 1px solid #666;
|
175
|
-
padding: 0.2em 0.5em 0 0.5em;
|
176
|
-
}
|
177
|
-
.method-signature { color: black; background: inherit; }
|
178
|
-
.method-name { font-weight: bold; }
|
179
|
-
.method-args { font-style: italic; }
|
180
|
-
.method-description { padding: 0 0.5em 0 0.5em; }
|
181
|
-
|
182
|
-
/* --- Source code sections -------------------- */
|
183
|
-
|
184
|
-
a.source-toggle { font-size: 90%; }
|
185
|
-
div.method-source-code {
|
186
|
-
background: #888888;
|
187
|
-
color: #ffdead;
|
188
|
-
margin: 1em;
|
189
|
-
padding: 0.5em;
|
190
|
-
border: 1px dashed #999;
|
191
|
-
overflow: hidden;
|
192
|
-
}
|
193
|
-
|
194
|
-
div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
195
|
-
|
196
|
-
/* --- Ruby keyword styles --------------------- */
|
197
|
-
|
198
|
-
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
|
199
|
-
|
200
|
-
.ruby-constant { color: #7fffd4; background: transparent; }
|
201
|
-
.ruby-keyword { color: #00ffff; background: transparent; }
|
202
|
-
.ruby-ivar { color: #eedd82; background: transparent; }
|
203
|
-
.ruby-operator { color: #00ffee; background: transparent; }
|
204
|
-
.ruby-identifier { color: #ffdead; background: transparent; }
|
205
|
-
.ruby-node { color: #ffa07a; background: transparent; }
|
206
|
-
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
|
207
|
-
.ruby-regexp { color: #ffa07a; background: transparent; }
|
208
|
-
.ruby-value { color: #7fffd4; background: transparent; }
|
data/lib/prelude/list.rb
DELETED
@@ -1,588 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# This file is part of the Prelude library that provides tools to
|
3
|
-
# enable Haskell style functional programming in Ruby.
|
4
|
-
#
|
5
|
-
# http://prelude.rubyforge.org
|
6
|
-
#
|
7
|
-
# Copyright (C) 2006 APP Design, Inc.
|
8
|
-
#
|
9
|
-
# This library is free software; you can redistribute it and/or
|
10
|
-
# modify it under the terms of the GNU Lesser General Public
|
11
|
-
# License as published by the Free Software Foundation; either
|
12
|
-
# version 2.1 of the License, or (at your option) any later version.
|
13
|
-
#
|
14
|
-
# This library is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
-
# Lesser General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU Lesser General Public
|
20
|
-
# License along with this library; if not, write to the Free Software
|
21
|
-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
22
|
-
#++
|
23
|
-
|
24
|
-
module Prelude
|
25
|
-
|
26
|
-
# $Id: list.rb 17 2006-09-17 18:03:15Z prelude $
|
27
|
-
#
|
28
|
-
# This eventually needs to be implemented with lazy lists, see
|
29
|
-
# http://lazylist.rubyforge.org for details
|
30
|
-
#
|
31
|
-
# I used the signatures of Haskell's List.hs file in order not to forget to implement
|
32
|
-
# the functions defined there and to remind of what was intended.
|
33
|
-
module List
|
34
|
-
|
35
|
-
# head -- :: [a] -> a
|
36
|
-
def head(list)
|
37
|
-
case list
|
38
|
-
when [] : empty_list_error
|
39
|
-
else lambda { list[0] }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# tail -- :: [a] -> [a]
|
44
|
-
def tail(list)
|
45
|
-
case list
|
46
|
-
when [] : empty_list_error
|
47
|
-
else lambda { list[1..-1] }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# last -- :: [a] -> a
|
52
|
-
def last(list)
|
53
|
-
case list
|
54
|
-
when [] : empty_list_error
|
55
|
-
when [list[0]] : lambda { list[0] }
|
56
|
-
else last(~tail(list))
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# init -- :: [a] -> [a]
|
61
|
-
def init(list)
|
62
|
-
case list
|
63
|
-
when [] : empty_list_error
|
64
|
-
when [list[0]] : lambda { [] }
|
65
|
-
else lambda { [~head(list)]+~init(~tail(list)) }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# null -- :: [a] -> Bool
|
70
|
-
def null(list)
|
71
|
-
lambda { list.size == 0 }
|
72
|
-
end
|
73
|
-
|
74
|
-
# length -- :: [a] -> Int
|
75
|
-
def length(list)
|
76
|
-
lambda { list.length }
|
77
|
-
end
|
78
|
-
|
79
|
-
# map -- :: (a -> b) -> [a] -> [b]
|
80
|
-
def map(f, list)
|
81
|
-
case list
|
82
|
-
when [] : lambda{ [] }
|
83
|
-
else lambda{ [ f[~head(list)] ] + ~map(f, ~tail(list)) }
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# , reverse -- :: [a] -> [a]
|
88
|
-
def reverse(list)
|
89
|
-
r = proc { |l, a|
|
90
|
-
case l
|
91
|
-
when [] : lambda { a }
|
92
|
-
else lambda { ~r[~tail(l), [~head(l)]+a] }
|
93
|
-
end
|
94
|
-
}
|
95
|
-
r[list, []]
|
96
|
-
end
|
97
|
-
|
98
|
-
# intersperse -- :: a -> [a] -> [a]
|
99
|
-
def intersperse(list)
|
100
|
-
warn "Method 'intersperse' is not implemented yet." if $VERBOSE
|
101
|
-
return lambda { [] }
|
102
|
-
end
|
103
|
-
|
104
|
-
# transpose -- :: [[a]] -> [[a]]
|
105
|
-
def transpose(list)
|
106
|
-
# FIXIT
|
107
|
-
lambda { list.transpose }
|
108
|
-
end
|
109
|
-
|
110
|
-
# # -- * Reducing lists (folds)
|
111
|
-
|
112
|
-
# foldl -- :: (a -> b -> a) -> a -> [b] -> a
|
113
|
-
def foldl(f, a, list)
|
114
|
-
case list
|
115
|
-
when [] : lambda { a }
|
116
|
-
else lambda { f[~foldl(f, a, ~tail(list)), ~head(list)] }
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
# foldl' -- :: (a -> b -> a) -> a -> [b] -> a
|
121
|
-
def foldl_(list)
|
122
|
-
warn "Method 'foldl_' is not implemented yet." if $VERBOSE
|
123
|
-
return lambda { [] }
|
124
|
-
end
|
125
|
-
|
126
|
-
# foldl1 -- :: (a -> a -> a) -> [a] -> a
|
127
|
-
def foldl1(f, list)
|
128
|
-
foldl(f, ~head(list), ~tail(list))
|
129
|
-
end
|
130
|
-
|
131
|
-
# foldl1' -- :: (a -> a -> a) -> [a] -> a
|
132
|
-
def foldl1_(list)
|
133
|
-
warn "Method 'foldl1_' is not implemented yet." if $VERBOSE
|
134
|
-
return lambda { [] }
|
135
|
-
end
|
136
|
-
|
137
|
-
# foldr -- :: (a -> b -> b) -> b -> [a] -> b
|
138
|
-
def foldr(f, s, list)
|
139
|
-
case list
|
140
|
-
when [] : lambda { s }
|
141
|
-
else lambda { f[~head(list), ~foldr(f, s, ~tail(list))] }
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
# foldr1 -- :: (a -> a -> a) -> [a] -> a
|
146
|
-
def foldr1(f, list)
|
147
|
-
foldr(f, ~head(list), ~tail(list))
|
148
|
-
end
|
149
|
-
|
150
|
-
# -- ** Special folds
|
151
|
-
|
152
|
-
# concat -- :: [[a]] -> [a]
|
153
|
-
def concat(list)
|
154
|
-
foldr(-:+, [], list)
|
155
|
-
end
|
156
|
-
|
157
|
-
# concatMap -- :: (a -> [b]) -> [a] -> [b]
|
158
|
-
def concat_map(list)
|
159
|
-
warn "Method 'concatMap' is not implemented yet." if $VERBOSE
|
160
|
-
return lambda { [] }
|
161
|
-
end
|
162
|
-
alias concatMap concat_map
|
163
|
-
|
164
|
-
# and -- :: [Bool] -> Bool
|
165
|
-
def and_(list)
|
166
|
-
foldr(lambda {|x,y| x && y}, true, list)
|
167
|
-
end
|
168
|
-
|
169
|
-
# or -- :: [Bool] -> Bool
|
170
|
-
def or_(list)
|
171
|
-
foldr(lambda {|x,y| (x || y)}, false, list)
|
172
|
-
end
|
173
|
-
|
174
|
-
# any -- :: (a -> Bool) -> [a] -> Bool
|
175
|
-
def any(f, list)
|
176
|
-
or_(~map(f, list))
|
177
|
-
end
|
178
|
-
|
179
|
-
# all -- :: (a -> Bool) -> [a] -> Bool
|
180
|
-
def all(f, list)
|
181
|
-
and_(~map(f, list))
|
182
|
-
end
|
183
|
-
|
184
|
-
# sum -- :: (Num a) => [a] -> a
|
185
|
-
def sum(list)
|
186
|
-
warn "Method 'sum' is not implemented yet." if $VERBOSE
|
187
|
-
return lambda { [] }
|
188
|
-
end
|
189
|
-
|
190
|
-
# product -- :: (Num a) => [a] -> a
|
191
|
-
def product(list)
|
192
|
-
warn "Method 'product' is not implemented yet." if $VERBOSE
|
193
|
-
return lambda { [] }
|
194
|
-
end
|
195
|
-
|
196
|
-
# maximum -- :: (Ord a) => [a] -> a
|
197
|
-
def maximum(list)
|
198
|
-
warn "Method 'maximum' is not implemented yet." if $VERBOSE
|
199
|
-
return lambda { [] }
|
200
|
-
end
|
201
|
-
|
202
|
-
# minimum -- :: (Ord a) => [a] -> a
|
203
|
-
def minimum(list)
|
204
|
-
warn "Method 'minimum' is not implemented yet." if $VERBOSE
|
205
|
-
return lambda { [] }
|
206
|
-
end
|
207
|
-
|
208
|
-
# -- * Building lists
|
209
|
-
|
210
|
-
# -- ** Scans
|
211
|
-
|
212
|
-
# scanl -- :: (a -> b -> a) -> a -> [b] -> [a]
|
213
|
-
def scanl(f, s, list)
|
214
|
-
warn "Method 'scanl' is not implemented yet." if $VERBOSE
|
215
|
-
return lambda { [] }
|
216
|
-
end
|
217
|
-
|
218
|
-
# scanl1 -- :: (a -> a -> a) -> [a] -> [a]
|
219
|
-
def scanl1(f, list)
|
220
|
-
warn "Method 'scanl1' is not implemented yet." if $VERBOSE
|
221
|
-
return lambda { [] }
|
222
|
-
end
|
223
|
-
|
224
|
-
# scanr -- :: (a -> b -> b) -> b -> [a] -> [b]
|
225
|
-
def scanr(f, s, list)
|
226
|
-
warn "Method 'scanr' is not implemented yet." if $VERBOSE
|
227
|
-
return lambda { [] }
|
228
|
-
end
|
229
|
-
|
230
|
-
# scanr1 -- :: (a -> a -> a) -> [a] -> [a]
|
231
|
-
def scanr1(f, list)
|
232
|
-
warn "Method 'scanr1' is not implemented yet." if $VERBOSE
|
233
|
-
return lambda { [] }
|
234
|
-
end
|
235
|
-
|
236
|
-
# -- ** Accumulating maps
|
237
|
-
|
238
|
-
# mapAccumL -- :: (a -> b -> (a,c)) -> a -> [b] -> (a,[c])
|
239
|
-
def map_accum_l(list)
|
240
|
-
warn "Method 'map_accum_l' is not implemented yet." if $VERBOSE
|
241
|
-
return lambda { [] }
|
242
|
-
end
|
243
|
-
|
244
|
-
alias mapAccumL map_accum_l
|
245
|
-
|
246
|
-
# mapAccumR -- :: (a -> b -> (a,c)) -> a -> [b] -> (a,[c])
|
247
|
-
def map_accum_r(list)
|
248
|
-
warn "Method 'map_accum_r' is not implemented yet." if $VERBOSE
|
249
|
-
return lambda { [] }
|
250
|
-
end
|
251
|
-
|
252
|
-
alias mapAccumR map_accum_r
|
253
|
-
|
254
|
-
# -- ** Infinite lists
|
255
|
-
|
256
|
-
# iterate -- :: (a -> a) -> a -> [a]
|
257
|
-
def iterate(list)
|
258
|
-
warn "Method 'iterate' is not implemented yet." if $VERBOSE
|
259
|
-
return lambda { [] }
|
260
|
-
end
|
261
|
-
|
262
|
-
# repeat -- :: a -> [a]
|
263
|
-
def repeat(list)
|
264
|
-
warn "Method 'repeat' is not implemented yet." if $VERBOSE
|
265
|
-
return lambda { [] }
|
266
|
-
end
|
267
|
-
|
268
|
-
# replicate -- :: Int -> a -> [a]
|
269
|
-
def replicate(list)
|
270
|
-
warn "Method 'replicate' is not implemented yet." if $VERBOSE
|
271
|
-
return lambda { [] }
|
272
|
-
end
|
273
|
-
|
274
|
-
# cycle -- :: [a] -> [a]
|
275
|
-
def cycle(list)
|
276
|
-
warn "Method 'cycle' is not implemented yet." if $VERBOSE
|
277
|
-
return lambda { [] }
|
278
|
-
end
|
279
|
-
|
280
|
-
# -- ** Unfolding
|
281
|
-
|
282
|
-
# unfoldr -- :: (b -> Maybe (a, b)) -> b -> [a]
|
283
|
-
def unfoldr(list)
|
284
|
-
warn "Method 'unfoldr' is not implemented yet." if $VERBOSE
|
285
|
-
return lambda { [] }
|
286
|
-
end
|
287
|
-
|
288
|
-
# -- * Sublists
|
289
|
-
|
290
|
-
# -- ** Extracting sublists
|
291
|
-
|
292
|
-
# take -- :: Int -> [a] -> [a]
|
293
|
-
def take(n, list)
|
294
|
-
lambda { list[0..(n-1)] }
|
295
|
-
end
|
296
|
-
|
297
|
-
# drop -- :: Int -> [a] -> [a]
|
298
|
-
def drop(n, list)
|
299
|
-
lambda { list[n..-1] }
|
300
|
-
end
|
301
|
-
|
302
|
-
# splitAt -- :: Int -> [a] -> ([a], [a])
|
303
|
-
def split_at(n, list)
|
304
|
-
lambda { [~take(n, list), ~drop(n, list)] }
|
305
|
-
end
|
306
|
-
|
307
|
-
# takeWhile -- :: (a -> Bool) -> [a] -> [a]
|
308
|
-
def take_while(p, list)
|
309
|
-
case list
|
310
|
-
when [] : lambda { [] }
|
311
|
-
else p[~head(list)] ? lambda { [~head(list)]+ ~take_while(p, ~tail(list)) } : lambda { [] }
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
alias takeWhile take_while
|
316
|
-
|
317
|
-
# dropWhile -- :: (a -> Bool) -> [a] -> [a]
|
318
|
-
def drop_while(p, list)
|
319
|
-
case list
|
320
|
-
when [] : lambda { [] }
|
321
|
-
else p[~head(list)] ? lambda { ~drop_while(p, ~tail(list)) } : lambda { list }
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
alias dropWhile drop_while
|
326
|
-
|
327
|
-
# span -- :: (a -> Bool) -> [a] -> ([a], [a])
|
328
|
-
def span(p, list)
|
329
|
-
lambda { [~takeWhile(p, list), ~dropWhile(p,list)] }
|
330
|
-
end
|
331
|
-
|
332
|
-
# break -- :: (a -> Bool) -> [a] -> ([a], [a])
|
333
|
-
def break_(list)
|
334
|
-
warn "Method 'break' is not implemented yet." if $VERBOSE
|
335
|
-
return lambda { [] }
|
336
|
-
end
|
337
|
-
|
338
|
-
# group -- :: Eq a => [a] -> [[a]]
|
339
|
-
def group(list)
|
340
|
-
warn "Method 'group' is not implemented yet." if $VERBOSE
|
341
|
-
return lambda { [] }
|
342
|
-
end
|
343
|
-
|
344
|
-
# inits -- :: [a] -> [[a]]
|
345
|
-
def inits(list)
|
346
|
-
warn "Method 'inits' is not implemented yet." if $VERBOSE
|
347
|
-
return lambda { [] }
|
348
|
-
end
|
349
|
-
|
350
|
-
# tails -- :: [a] -> [[a]]
|
351
|
-
def tails(list)
|
352
|
-
warn "Method 'tails' is not implemented yet." if $VERBOSE
|
353
|
-
return lambda { [] }
|
354
|
-
end
|
355
|
-
|
356
|
-
# -- ** Predicates
|
357
|
-
|
358
|
-
# isPrefixOf -- :: (Eq a) => [a] -> [a] -> Bool
|
359
|
-
def is_prefix_of(list)
|
360
|
-
warn "Method 'is_prefix_of' is not implemented yet." if $VERBOSE
|
361
|
-
return lambda { [] }
|
362
|
-
end
|
363
|
-
|
364
|
-
alias isPrefixOf is_prefix_of
|
365
|
-
|
366
|
-
# isSuffixOf -- :: (Eq a) => [a] -> [a] -> Bool
|
367
|
-
def is_suffix_of(list)
|
368
|
-
warn "Method 'is_suffix_of' is not implemented yet." if $VERBOSE
|
369
|
-
return lambda { [] }
|
370
|
-
end
|
371
|
-
|
372
|
-
alias isSuffixOf is_suffix_of
|
373
|
-
|
374
|
-
# -- * Searching lists
|
375
|
-
|
376
|
-
# -- ** Searching by equality
|
377
|
-
|
378
|
-
# elem -- :: a -> [a] -> Bool
|
379
|
-
def elem(list)
|
380
|
-
warn "Method 'elem' is not implemented yet." if $VERBOSE
|
381
|
-
return lambda { [] }
|
382
|
-
end
|
383
|
-
|
384
|
-
# notElem -- :: a -> [a] -> Bool
|
385
|
-
def not_elem(list)
|
386
|
-
warn "Method 'not_elem' is not implemented yet." if $VERBOSE
|
387
|
-
return lambda { [] }
|
388
|
-
end
|
389
|
-
|
390
|
-
alias notElem not_elem
|
391
|
-
|
392
|
-
# lookup -- :: (Eq a) => a -> [(a,b)] -> Maybe b
|
393
|
-
def lookup(list)
|
394
|
-
warn "Method 'lookup' is not implemented yet." if $VERBOSE
|
395
|
-
return lambda { [] }
|
396
|
-
end
|
397
|
-
|
398
|
-
# -- ** Searching with a predicate
|
399
|
-
|
400
|
-
# find -- :: (a -> Bool) -> [a] -> Maybe a
|
401
|
-
def find(p, list)
|
402
|
-
warn "Method 'find' is not implemented yet." if $VERBOSE
|
403
|
-
return lambda { [] }
|
404
|
-
end
|
405
|
-
|
406
|
-
# filter -- :: (a -> Bool) -> [a] -> [a]
|
407
|
-
def filter(list)
|
408
|
-
warn "Method 'filter' is not implemented yet." if $VERBOSE
|
409
|
-
return lambda { [] }
|
410
|
-
end
|
411
|
-
|
412
|
-
# partition -- :: (a -> Bool) -> [a] -> ([a], [a])
|
413
|
-
def partition(p, list)
|
414
|
-
warn "Method 'partition' is not implemented yet." if $VERBOSE
|
415
|
-
return lambda { [] }
|
416
|
-
end
|
417
|
-
|
418
|
-
# -- * Indexing lists
|
419
|
-
|
420
|
-
# -- | These functions treat a list @xs@ as a indexed collection,
|
421
|
-
# -- with indices ranging from 0 to @'length' xs - 1@.
|
422
|
-
|
423
|
-
|
424
|
-
# elemIndex -- :: (Eq a) => a -> [a] -> Maybe Int
|
425
|
-
def elem_index(list)
|
426
|
-
warn "Method 'elem_index' is not implemented yet." if $VERBOSE
|
427
|
-
return lambda { [] }
|
428
|
-
end
|
429
|
-
|
430
|
-
alias elemIndex elem_index
|
431
|
-
|
432
|
-
# elemIndices -- :: (Eq a) => a -> [a] -> [Int]
|
433
|
-
def elem_indices(list)
|
434
|
-
warn "Method 'elem_indices' is not implemented yet." if $VERBOSE
|
435
|
-
return lambda { [] }
|
436
|
-
end
|
437
|
-
|
438
|
-
alias elemIndices elem_indices
|
439
|
-
|
440
|
-
# findIndex -- :: (a -> Bool) -> [a] -> Maybe Int
|
441
|
-
def find_index(list)
|
442
|
-
warn "Method 'find_index' is not implemented yet." if $VERBOSE
|
443
|
-
return lambda { [] }
|
444
|
-
end
|
445
|
-
|
446
|
-
alias findIndex find_index
|
447
|
-
|
448
|
-
# findIndices -- :: (a -> Bool) -> [a] -> [Int]
|
449
|
-
def find_indices(list)
|
450
|
-
warn "Method 'find_indices' is not implemented yet." if $VERBOSE
|
451
|
-
return lambda { [] }
|
452
|
-
end
|
453
|
-
|
454
|
-
alias findIndices find_indices
|
455
|
-
|
456
|
-
# -- * Zipping and unzipping lists
|
457
|
-
|
458
|
-
# zip -- :: [a] -> [b] -> [(a,b)]
|
459
|
-
def zip(list1, list2)
|
460
|
-
warn "Method 'zip' is not implemented yet." if $VERBOSE
|
461
|
-
return lambda { [] }
|
462
|
-
end
|
463
|
-
|
464
|
-
# zip3
|
465
|
-
def zip3(list)
|
466
|
-
warn "Method 'zip3' is not implemented yet." if $VERBOSE
|
467
|
-
return lambda { [] }
|
468
|
-
end
|
469
|
-
|
470
|
-
# zip4, zip5, zip6, zip7
|
471
|
-
def zip4(list)
|
472
|
-
warn "Method 'zip4' is not implemented yet." if $VERBOSE
|
473
|
-
return lambda { [] }
|
474
|
-
end
|
475
|
-
|
476
|
-
# zipWith -- :: (a -> b -> c) -> [a] -> [b] -> [c]
|
477
|
-
def zip_with(list)
|
478
|
-
warn "Method 'zip_with' is not implemented yet." if $VERBOSE
|
479
|
-
return lambda { [] }
|
480
|
-
end
|
481
|
-
|
482
|
-
alias zipWith zip_with
|
483
|
-
|
484
|
-
# zipWith3
|
485
|
-
def zip_with3(list)
|
486
|
-
warn "Method 'zip_with3' is not implemented yet." if $VERBOSE
|
487
|
-
return lambda { [] }
|
488
|
-
end
|
489
|
-
|
490
|
-
alias zipWith3 zip_with3
|
491
|
-
|
492
|
-
# zipWith4, zipWith5, zipWith6, zipWith7
|
493
|
-
def zip_with4(list)
|
494
|
-
warn "Method 'zip_with4' is not implemented yet." if $VERBOSE
|
495
|
-
return lambda { [] }
|
496
|
-
end
|
497
|
-
|
498
|
-
alias zipWith4 zip_with4
|
499
|
-
|
500
|
-
# unzip -- :: [(a,b)] -> ([a],[b])
|
501
|
-
def unzip(list)
|
502
|
-
warn "Method 'unzip' is not implemented yet." if $VERBOSE
|
503
|
-
return lambda { [] }
|
504
|
-
end
|
505
|
-
|
506
|
-
# unzip3
|
507
|
-
def unzip3(list)
|
508
|
-
warn "Method 'unzip3' is not implemented yet." if $VERBOSE
|
509
|
-
return lambda { [] }
|
510
|
-
end
|
511
|
-
|
512
|
-
# unzip4, unzip5, unzip6, unzip7
|
513
|
-
def unzip4(list)
|
514
|
-
warn "Method 'unzip4' is not implemented yet." if $VERBOSE
|
515
|
-
return lambda { [] }
|
516
|
-
end
|
517
|
-
|
518
|
-
# -- * Special lists
|
519
|
-
|
520
|
-
# -- ** Functions on strings
|
521
|
-
|
522
|
-
# lines -- :: String -> [String]
|
523
|
-
def lines(list)
|
524
|
-
warn "Method 'lines' is not implemented yet." if $VERBOSE
|
525
|
-
return lambda { [] }
|
526
|
-
end
|
527
|
-
|
528
|
-
# words -- :: String -> [String]
|
529
|
-
def words(list)
|
530
|
-
warn "Method 'words' is not implemented yet." if $VERBOSE
|
531
|
-
return lambda { [] }
|
532
|
-
end
|
533
|
-
|
534
|
-
# unlines -- :: [String] -> String
|
535
|
-
def unlines(list)
|
536
|
-
warn "Method 'unlines' is not implemented yet." if $VERBOSE
|
537
|
-
return lambda { [] }
|
538
|
-
end
|
539
|
-
|
540
|
-
# unwords -- :: [String] -> String
|
541
|
-
def unwords(list)
|
542
|
-
warn "Method 'unwords' is not implemented yet." if $VERBOSE
|
543
|
-
return lambda { [] }
|
544
|
-
end
|
545
|
-
|
546
|
-
# -- ** \"Set\" operations
|
547
|
-
|
548
|
-
# nub -- :: (Eq a) => [a] -> [a]
|
549
|
-
def nub(list)
|
550
|
-
warn "Method 'nub' is not implemented yet." if $VERBOSE
|
551
|
-
return lambda { [] }
|
552
|
-
end
|
553
|
-
|
554
|
-
# delete -- :: (Eq a) => a -> [a] -> [a]
|
555
|
-
def delete(o, list)
|
556
|
-
warn "Method 'delete' is not implemented yet." if $VERBOSE
|
557
|
-
return lambda { [] }
|
558
|
-
end
|
559
|
-
|
560
|
-
# union -- :: (Eq a) => [a] -> [a] -> [a]
|
561
|
-
def union(list)
|
562
|
-
warn "Method 'union' is not implemented yet." if $VERBOSE
|
563
|
-
return lambda { [] }
|
564
|
-
end
|
565
|
-
|
566
|
-
# intersect -- :: (Eq a) => [a] -> [a] -> [a]
|
567
|
-
def intersect(list)
|
568
|
-
warn "Method 'intersect' is not implemented yet." if $VERBOSE
|
569
|
-
return lambda { [] }
|
570
|
-
end
|
571
|
-
|
572
|
-
# -- ** Ordered lists
|
573
|
-
|
574
|
-
# sort -- :: (Ord a) => [a] -> [a]
|
575
|
-
def sort(list)
|
576
|
-
warn "Method 'sort' is not implemented yet." if $VERBOSE
|
577
|
-
return lambda { [] }
|
578
|
-
end
|
579
|
-
|
580
|
-
# insert -- :: (Ord a) => a -> [a] -> [a]
|
581
|
-
def insert(o, list)
|
582
|
-
warn "Method 'insert' is not implemented yet." if $VERBOSE
|
583
|
-
return lambda { [] }
|
584
|
-
end
|
585
|
-
|
586
|
-
end # List
|
587
|
-
|
588
|
-
end # Prelude
|