prelude 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +11 -3
- data/COPYING +410 -247
- data/README +139 -9
- data/Rakefile +22 -19
- data/doc/classes/Prelude.html +134 -0
- data/doc/classes/Prelude/List.html +2549 -0
- data/doc/classes/Prelude/Monad.html +226 -0
- data/doc/classes/Prelude/Tuple.html +217 -0
- data/doc/classes/Proc.html +173 -0
- data/doc/classes/Symbol.html +166 -0
- data/doc/created.rid +1 -0
- data/doc/files/CHANGELOG.html +115 -0
- data/doc/files/README.html +328 -0
- data/doc/files/TODO.html +95 -0
- data/doc/files/lib/prelude/list_rb.html +83 -0
- data/doc/files/lib/prelude/monad_rb.html +83 -0
- data/doc/files/lib/prelude/tuple_rb.html +83 -0
- data/doc/files/lib/prelude_rb.html +98 -0
- data/doc/fr_class_index.html +32 -0
- data/doc/fr_file_index.html +33 -0
- data/doc/fr_method_index.html +124 -0
- data/doc/index.html +27 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/prelude.rb +12 -15
- data/lib/prelude/list.rb +115 -131
- data/lib/prelude/monad.rb +31 -19
- data/lib/prelude/tuple.rb +27 -31
- data/test/tc_higher.rb +11 -11
- data/test/tc_list.rb +29 -15
- data/test/tc_tuple.rb +49 -11
- data/test/ts_prelude.rb +11 -11
- metadata +27 -3
data/lib/prelude/list.rb
CHANGED
@@ -6,224 +6,221 @@
|
|
6
6
|
#
|
7
7
|
# Copyright (C) 2006 APP Design, Inc.
|
8
8
|
#
|
9
|
-
# This
|
10
|
-
# it under the terms of the GNU General Public
|
11
|
-
# the Free Software Foundation; either
|
12
|
-
# (at your option) any later version.
|
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
13
|
#
|
14
|
-
# This
|
14
|
+
# This library is distributed in the hope that it will be useful,
|
15
15
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
#
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
# Lesser General Public License for more details.
|
18
18
|
#
|
19
|
-
# You should have received a copy of the GNU General Public
|
20
|
-
# with this
|
21
|
-
# 51 Franklin Street, Fifth Floor, Boston, MA
|
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
22
|
#++
|
23
23
|
|
24
24
|
module Prelude
|
25
25
|
|
26
|
-
# $Id: list.rb
|
27
|
-
#
|
28
|
-
# This code is inspired in part by Hipster, <hipster xs4all.nl> (a.k.a. Michel
|
29
|
-
# van de Ven), and his original sketch was initially located at
|
30
|
-
# http://www.xs4all.nl/~hipster/lib/ruby/haskell
|
26
|
+
# $Id: list.rb 7 2006-09-06 17:03:26Z prelude $
|
31
27
|
#
|
32
28
|
# This eventually needs to be implemented with lazy lists, see
|
33
29
|
# http://lazylist.rubyforge.org for details
|
34
30
|
#
|
35
31
|
# I used the signatures of Haskell's List.hs file in order not to forget to implement
|
36
32
|
# the functions defined there and to remind of what was intended.
|
33
|
+
#
|
34
|
+
# The following methods are implemented by Array with the same semantics:
|
35
|
+
# * last -- :: [a] -> a
|
36
|
+
# * length -- :: [a] -> Int
|
37
|
+
# * map -- :: (a -> b) -> [a] -> [b]
|
38
|
+
# * reverse -- :: [a] -> [a]
|
39
|
+
# * transpose -- :: [[a]] -> [[a]]
|
40
|
+
# * find -- :: (a -> Bool) -> [a] -> Maybe a
|
41
|
+
# * partition -- :: (a -> Bool) -> [a] -> ([a], [a])
|
42
|
+
# * zip -- :: [a] -> [b] -> [(a,b)]
|
43
|
+
# * sort -- :: (Ord a) => [a] -> [a]
|
44
|
+
#
|
45
|
+
# I do not know how to implement these in Ruby:
|
46
|
+
# * (!!) -- :: [a] -> Int -> a
|
47
|
+
# * (\\) -- :: (Eq a) => [a] -> [a] -> [a]
|
48
|
+
|
37
49
|
class List < Array
|
38
50
|
|
39
51
|
# Array compatibility functions
|
52
|
+
|
40
53
|
alias array_plus +
|
41
54
|
|
42
55
|
def +(o)
|
43
56
|
List.new(self.array_plus(o))
|
44
57
|
end
|
45
58
|
|
46
|
-
#
|
59
|
+
# head -- :: [a] -> a
|
47
60
|
def head
|
48
61
|
self[0]
|
49
62
|
end
|
50
63
|
|
51
|
-
#
|
52
|
-
# already defined by the Array
|
53
|
-
|
54
|
-
# , tail -- :: [a] -> [a]
|
64
|
+
# tail -- :: [a] -> [a]
|
55
65
|
def tail
|
56
66
|
self[1..-1]
|
57
67
|
end
|
58
68
|
|
59
|
-
#
|
69
|
+
# init -- :: [a] -> [a]
|
60
70
|
def init
|
61
71
|
self[0..-2]
|
62
72
|
end
|
63
73
|
|
64
|
-
#
|
74
|
+
# null -- :: [a] -> Bool
|
65
75
|
def null
|
66
76
|
size == 0
|
67
77
|
end
|
68
78
|
|
69
|
-
#
|
70
|
-
# Implemented by Array
|
71
|
-
|
72
|
-
# -- * List transformations
|
73
|
-
# , map -- :: (a -> b) -> [a] -> [b]
|
74
|
-
# Implemented by Array
|
75
|
-
|
76
|
-
# , reverse -- :: [a] -> [a]
|
77
|
-
# Implemented by Array
|
78
|
-
|
79
|
-
# , intersperse -- :: a -> [a] -> [a]
|
79
|
+
# intersperse -- :: a -> [a] -> [a]
|
80
80
|
def intersperse
|
81
81
|
warn "Method 'intersperse' is not implemented yet." if $VERBOSE
|
82
82
|
return []
|
83
83
|
end
|
84
84
|
|
85
|
-
# , transpose -- :: [[a]] -> [[a]]
|
86
|
-
# Implemented by Array
|
87
|
-
|
88
85
|
# -- * Reducing lists (folds)
|
89
86
|
|
90
|
-
# , foldl -- :: (a -> b -> a) -> a -> [b] -> a
|
91
|
-
|
92
87
|
# Classic recursive functional definition causes stack overflow for
|
93
88
|
# arrays of any usable size... So don't use it, it's here for
|
94
|
-
# demonstration purposes only
|
89
|
+
# demonstration purposes only. Use #foldl.
|
95
90
|
def f_foldl(s, &block)
|
96
91
|
empty? ? s : tail.f_foldl(block.call(s, head), &block)
|
97
92
|
end
|
98
93
|
|
99
|
-
# This is a more pedestrian iterative version
|
94
|
+
# This is a more pedestrian iterative version of f_foldl
|
95
|
+
# foldl -- :: (a -> b -> a) -> a -> [b] -> a
|
100
96
|
def foldl(s, &block)
|
101
97
|
inject(s){ |a,b| block.call(a,b) }
|
102
98
|
end
|
103
99
|
|
104
|
-
#
|
100
|
+
# foldl' -- :: (a -> b -> a) -> a -> [b] -> a
|
105
101
|
def foldl_
|
106
102
|
warn "Method 'foldl_' is not implemented yet." if $VERBOSE
|
107
103
|
return []
|
108
104
|
end
|
109
105
|
|
110
|
-
#
|
106
|
+
# foldl1 -- :: (a -> a -> a) -> [a] -> a
|
111
107
|
def foldl1(&block)
|
112
108
|
tail.foldl(head, &block)
|
113
109
|
end
|
114
110
|
|
115
|
-
#
|
111
|
+
# foldl1' -- :: (a -> a -> a) -> [a] -> a
|
116
112
|
def foldl1_
|
117
113
|
warn "Method 'foldl1_' is not implemented yet." if $VERBOSE
|
118
114
|
return []
|
119
115
|
end
|
120
116
|
|
121
|
-
#
|
117
|
+
# foldr -- :: (a -> b -> b) -> b -> [a] -> b
|
122
118
|
def foldr(s, &block)
|
123
119
|
inject(s){ |a,b| block.call(b, a) }
|
124
120
|
end
|
125
121
|
|
126
|
-
#
|
122
|
+
# foldr1 -- :: (a -> a -> a) -> [a] -> a
|
127
123
|
def foldr1(&block)
|
128
124
|
tail.foldr(head, &block)
|
129
125
|
end
|
130
126
|
|
131
127
|
# -- ** Special folds
|
132
128
|
|
133
|
-
# , concat -- :: [[a]] -> [a]
|
134
129
|
# Implemented by Array but semantics is different
|
130
|
+
# concat -- :: [[a]] -> [a]
|
135
131
|
def concat
|
136
132
|
flatten
|
137
133
|
end
|
138
134
|
|
139
|
-
|
140
|
-
# , concatMap -- :: (a -> [b]) -> [a] -> [b]
|
135
|
+
# concatMap -- :: (a -> [b]) -> [a] -> [b]
|
141
136
|
def concat_map
|
142
137
|
warn "Method 'concatMap' is not implemented yet." if $VERBOSE
|
143
138
|
return []
|
144
139
|
end
|
145
140
|
alias concatMap concat_map
|
146
141
|
|
147
|
-
#
|
142
|
+
# and -- :: [Bool] -> Bool
|
148
143
|
def and
|
149
144
|
foldr(true){|x,y| x && y}
|
150
145
|
end
|
151
146
|
|
152
|
-
#
|
147
|
+
# or -- :: [Bool] -> Bool
|
153
148
|
def or
|
154
149
|
foldr(false){|x,y| (x || y)}
|
155
150
|
end
|
156
151
|
|
157
|
-
#
|
152
|
+
# any -- :: (a -> Bool) -> [a] -> Bool
|
158
153
|
def any(&block)
|
159
154
|
each{|e| return true if block.call(e)}
|
160
155
|
return false
|
161
156
|
end
|
162
157
|
|
163
|
-
#
|
158
|
+
# all -- :: (a -> Bool) -> [a] -> Bool
|
164
159
|
def all(&block)
|
165
160
|
each{|e| return false unless block.call(e)}
|
166
161
|
return true
|
167
162
|
end
|
168
163
|
|
169
|
-
#
|
164
|
+
# sum -- :: (Num a) => [a] -> a
|
170
165
|
def sum
|
171
166
|
warn "Method 'sum' is not implemented yet." if $VERBOSE
|
172
167
|
return []
|
173
168
|
end
|
174
169
|
|
175
|
-
#
|
170
|
+
# product -- :: (Num a) => [a] -> a
|
176
171
|
def product
|
177
172
|
warn "Method 'product' is not implemented yet." if $VERBOSE
|
178
173
|
return []
|
179
174
|
end
|
180
175
|
|
181
|
-
#
|
176
|
+
# maximum -- :: (Ord a) => [a] -> a
|
182
177
|
def maximum
|
183
178
|
warn "Method 'maximum' is not implemented yet." if $VERBOSE
|
184
179
|
return []
|
185
180
|
end
|
186
181
|
|
187
|
-
#
|
182
|
+
# minimum -- :: (Ord a) => [a] -> a
|
188
183
|
def minimum
|
189
184
|
warn "Method 'minimum' is not implemented yet." if $VERBOSE
|
190
185
|
return []
|
191
186
|
end
|
192
187
|
|
193
188
|
|
194
|
-
#
|
189
|
+
# -- * Building lists
|
190
|
+
|
191
|
+
# -- ** Scans
|
195
192
|
|
196
|
-
#
|
197
|
-
# , scanl -- :: (a -> b -> a) -> a -> [b] -> [a]
|
193
|
+
# scanl -- :: (a -> b -> a) -> a -> [b] -> [a]
|
198
194
|
def scanl(s, &block)
|
199
195
|
inject([s]){ |a,b| a << block.call(a.last,b) }
|
200
196
|
end
|
201
197
|
|
202
|
-
#
|
198
|
+
# scanl1 -- :: (a -> a -> a) -> [a] -> [a]
|
203
199
|
def scanl1(&block)
|
204
200
|
tail.scanl(head, &block)
|
205
201
|
end
|
206
202
|
|
207
|
-
#
|
203
|
+
# scanr -- :: (a -> b -> b) -> b -> [a] -> [b]
|
208
204
|
def scanr(s, &block)
|
209
205
|
inject([s]){ |a,b| a << block.call(b, a.last) }
|
210
206
|
end
|
211
207
|
|
212
|
-
#
|
208
|
+
# scanr1 -- :: (a -> a -> a) -> [a] -> [a]
|
213
209
|
def scanr1(&block)
|
214
210
|
tail.scanr(head, &block)
|
215
211
|
end
|
216
212
|
|
217
213
|
|
218
214
|
# -- ** Accumulating maps
|
219
|
-
|
215
|
+
|
216
|
+
# mapAccumL -- :: (a -> b -> (a,c)) -> a -> [b] -> (a,[c])
|
220
217
|
def map_accum_l
|
221
218
|
warn "Method 'map_accum_l' is not implemented yet." if $VERBOSE
|
222
219
|
return []
|
223
220
|
end
|
224
221
|
alias mapAccumL map_accum_l
|
225
222
|
|
226
|
-
#
|
223
|
+
# mapAccumR -- :: (a -> b -> (a,c)) -> a -> [b] -> (a,[c])
|
227
224
|
def map_accum_r
|
228
225
|
warn "Method 'map_accum_r' is not implemented yet." if $VERBOSE
|
229
226
|
return []
|
@@ -232,25 +229,26 @@ module Prelude
|
|
232
229
|
|
233
230
|
|
234
231
|
# -- ** Infinite lists
|
235
|
-
|
232
|
+
|
233
|
+
# iterate -- :: (a -> a) -> a -> [a]
|
236
234
|
def iterate
|
237
235
|
warn "Method 'iterate' is not implemented yet." if $VERBOSE
|
238
236
|
return []
|
239
237
|
end
|
240
238
|
|
241
|
-
#
|
239
|
+
# repeat -- :: a -> [a]
|
242
240
|
def repeat
|
243
241
|
warn "Method 'repeat' is not implemented yet." if $VERBOSE
|
244
242
|
return []
|
245
243
|
end
|
246
244
|
|
247
|
-
#
|
245
|
+
# replicate -- :: Int -> a -> [a]
|
248
246
|
def replicate
|
249
247
|
warn "Method 'replicate' is not implemented yet." if $VERBOSE
|
250
248
|
return []
|
251
249
|
end
|
252
250
|
|
253
|
-
#
|
251
|
+
# cycle -- :: [a] -> [a]
|
254
252
|
def cycle
|
255
253
|
warn "Method 'cycle' is not implemented yet." if $VERBOSE
|
256
254
|
return []
|
@@ -258,33 +256,35 @@ module Prelude
|
|
258
256
|
|
259
257
|
|
260
258
|
# -- ** Unfolding
|
261
|
-
|
259
|
+
|
260
|
+
# unfoldr -- :: (b -> Maybe (a, b)) -> b -> [a]
|
262
261
|
def unfoldr
|
263
262
|
warn "Method 'unfoldr' is not implemented yet." if $VERBOSE
|
264
263
|
return []
|
265
264
|
end
|
266
265
|
|
267
266
|
|
268
|
-
#
|
267
|
+
# -- * Sublists
|
269
268
|
|
270
|
-
#
|
271
|
-
|
269
|
+
# -- ** Extracting sublists
|
270
|
+
|
271
|
+
# take -- :: Int -> [a] -> [a]
|
272
272
|
def take(n)
|
273
273
|
self[0..(n-1)]
|
274
274
|
end
|
275
275
|
|
276
|
-
#
|
276
|
+
# drop -- :: Int -> [a] -> [a]
|
277
277
|
def drop(n)
|
278
278
|
self[n..-1]
|
279
279
|
end
|
280
280
|
|
281
|
-
#
|
281
|
+
# splitAt -- :: Int -> [a] -> ([a], [a])
|
282
282
|
def split_at(n)
|
283
283
|
[take(n), drop(n)]
|
284
284
|
end
|
285
285
|
alias splitAt split_at
|
286
286
|
|
287
|
-
#
|
287
|
+
# takeWhile -- :: (a -> Bool) -> [a] -> [a]
|
288
288
|
def take_while
|
289
289
|
r = []
|
290
290
|
each{ |e|
|
@@ -295,7 +295,7 @@ module Prelude
|
|
295
295
|
end
|
296
296
|
alias takeWhile take_while
|
297
297
|
|
298
|
-
#
|
298
|
+
# dropWhile -- :: (a -> Bool) -> [a] -> [a]
|
299
299
|
def drop_while
|
300
300
|
r = []
|
301
301
|
each{ |e|
|
@@ -306,116 +306,111 @@ module Prelude
|
|
306
306
|
end
|
307
307
|
alias dropWhile drop_while
|
308
308
|
|
309
|
-
#
|
309
|
+
# span -- :: (a -> Bool) -> [a] -> ([a], [a])
|
310
310
|
def span(&block)
|
311
311
|
[take_while(&block), drop_while(&block)]
|
312
312
|
end
|
313
313
|
|
314
|
-
#
|
314
|
+
# break -- :: (a -> Bool) -> [a] -> ([a], [a])
|
315
315
|
def break
|
316
316
|
warn "Method 'break' is not implemented yet." if $VERBOSE
|
317
317
|
return []
|
318
318
|
end
|
319
319
|
|
320
|
-
#
|
320
|
+
# group -- :: Eq a => [a] -> [[a]]
|
321
321
|
def group
|
322
322
|
warn "Method 'group' is not implemented yet." if $VERBOSE
|
323
323
|
return []
|
324
324
|
end
|
325
325
|
|
326
|
-
#
|
326
|
+
# inits -- :: [a] -> [[a]]
|
327
327
|
def inits
|
328
328
|
warn "Method 'inits' is not implemented yet." if $VERBOSE
|
329
329
|
return []
|
330
330
|
end
|
331
331
|
|
332
|
-
#
|
332
|
+
# tails -- :: [a] -> [[a]]
|
333
333
|
def tails
|
334
334
|
warn "Method 'tails' is not implemented yet." if $VERBOSE
|
335
335
|
return []
|
336
336
|
end
|
337
337
|
|
338
338
|
# -- ** Predicates
|
339
|
-
|
339
|
+
|
340
|
+
# isPrefixOf -- :: (Eq a) => [a] -> [a] -> Bool
|
340
341
|
def is_prefix_of
|
341
342
|
warn "Method 'is_prefix_of' is not implemented yet." if $VERBOSE
|
342
343
|
return []
|
343
344
|
end
|
344
345
|
alias isPrefixOf is_prefix_of
|
345
346
|
|
346
|
-
#
|
347
|
+
# isSuffixOf -- :: (Eq a) => [a] -> [a] -> Bool
|
347
348
|
def is_suffix_of
|
348
349
|
warn "Method 'is_suffix_of' is not implemented yet." if $VERBOSE
|
349
350
|
return []
|
350
351
|
end
|
351
352
|
alias isSuffixOf is_suffix_of
|
352
353
|
|
353
|
-
#
|
354
|
+
# -- * Searching lists
|
354
355
|
|
355
356
|
# -- ** Searching by equality
|
356
|
-
|
357
|
+
|
358
|
+
# elem -- :: a -> [a] -> Bool
|
357
359
|
def elem
|
358
360
|
warn "Method 'elem' is not implemented yet." if $VERBOSE
|
359
361
|
return []
|
360
362
|
end
|
361
363
|
|
362
|
-
#
|
364
|
+
# notElem -- :: a -> [a] -> Bool
|
363
365
|
def not_elem
|
364
366
|
warn "Method 'not_elem' is not implemented yet." if $VERBOSE
|
365
367
|
return []
|
366
368
|
end
|
367
369
|
alias notElem not_elem
|
368
370
|
|
369
|
-
#
|
371
|
+
# lookup -- :: (Eq a) => a -> [(a,b)] -> Maybe b
|
370
372
|
def lookup
|
371
373
|
warn "Method 'lookup' is not implemented yet." if $VERBOSE
|
372
374
|
return []
|
373
375
|
end
|
374
376
|
|
375
377
|
# -- ** Searching with a predicate
|
376
|
-
# , find -- :: (a -> Bool) -> [a] -> Maybe a
|
377
|
-
# Implemented by Array
|
378
378
|
|
379
|
-
#
|
379
|
+
# filter -- :: (a -> Bool) -> [a] -> [a]
|
380
380
|
def filter
|
381
381
|
warn "Method 'filter' is not implemented yet." if $VERBOSE
|
382
382
|
return []
|
383
383
|
end
|
384
384
|
|
385
|
-
# , partition -- :: (a -> Bool) -> [a] -> ([a], [a])
|
386
|
-
# Implemented by Array
|
387
385
|
|
386
|
+
# -- * Indexing lists
|
388
387
|
|
389
|
-
# -- * Indexing lists
|
390
388
|
# -- | These functions treat a list @xs@ as a indexed collection,
|
391
389
|
# -- with indices ranging from 0 to @'length' xs - 1@.
|
392
390
|
|
393
|
-
# , (!!) -- :: [a] -> Int -> a
|
394
|
-
# Don't know how to implement it in Ruby
|
395
|
-
|
396
391
|
|
397
|
-
#
|
392
|
+
# elemIndex -- :: (Eq a) => a -> [a] -> Maybe Int
|
398
393
|
def elem_index
|
399
394
|
warn "Method 'elem_index' is not implemented yet." if $VERBOSE
|
400
395
|
return []
|
401
396
|
end
|
402
397
|
alias elemIndex elem_index
|
403
398
|
|
404
|
-
#
|
399
|
+
# elemIndices -- :: (Eq a) => a -> [a] -> [Int]
|
405
400
|
def elem_indices
|
406
401
|
warn "Method 'elem_indices' is not implemented yet." if $VERBOSE
|
407
402
|
return []
|
408
403
|
end
|
409
404
|
alias elemIndices elem_indices
|
410
405
|
|
411
|
-
#
|
406
|
+
# findIndex -- :: (a -> Bool) -> [a] -> Maybe Int
|
412
407
|
def find_index
|
413
408
|
warn "Method 'find_index' is not implemented yet." if $VERBOSE
|
414
409
|
return []
|
415
410
|
end
|
416
411
|
alias findIndex find_index
|
417
412
|
|
418
|
-
#
|
413
|
+
# findIndices -- :: (a -> Bool) -> [a] -> [Int]
|
419
414
|
def find_indices
|
420
415
|
warn "Method 'find_indices' is not implemented yet." if $VERBOSE
|
421
416
|
return []
|
@@ -423,39 +418,36 @@ module Prelude
|
|
423
418
|
alias findIndices find_indices
|
424
419
|
|
425
420
|
|
426
|
-
#
|
427
|
-
|
428
|
-
# , zip -- :: [a] -> [b] -> [(a,b)]
|
429
|
-
# Implemented by Array
|
421
|
+
# -- * Zipping and unzipping lists
|
430
422
|
|
431
|
-
#
|
423
|
+
# zip3
|
432
424
|
def zip3
|
433
425
|
warn "Method 'zip3' is not implemented yet." if $VERBOSE
|
434
426
|
return []
|
435
427
|
end
|
436
428
|
|
437
|
-
#
|
429
|
+
# zip4, zip5, zip6, zip7
|
438
430
|
def zip4
|
439
431
|
warn "Method 'zip4' is not implemented yet." if $VERBOSE
|
440
432
|
return []
|
441
433
|
end
|
442
434
|
|
443
435
|
|
444
|
-
#
|
436
|
+
# zipWith -- :: (a -> b -> c) -> [a] -> [b] -> [c]
|
445
437
|
def zip_with
|
446
438
|
warn "Method 'zip_with' is not implemented yet." if $VERBOSE
|
447
439
|
return []
|
448
440
|
end
|
449
441
|
alias zipWith zip_with
|
450
442
|
|
451
|
-
#
|
443
|
+
# zipWith3
|
452
444
|
def zip_with3
|
453
445
|
warn "Method 'zip_with3' is not implemented yet." if $VERBOSE
|
454
446
|
return []
|
455
447
|
end
|
456
448
|
alias zipWith3 zip_with3
|
457
449
|
|
458
|
-
#
|
450
|
+
# zipWith4, zipWith5, zipWith6, zipWith7
|
459
451
|
def zip_with4
|
460
452
|
warn "Method 'zip_with4' is not implemented yet." if $VERBOSE
|
461
453
|
return []
|
@@ -463,47 +455,48 @@ module Prelude
|
|
463
455
|
alias zipWith4 zip_with4
|
464
456
|
|
465
457
|
|
466
|
-
#
|
458
|
+
# unzip -- :: [(a,b)] -> ([a],[b])
|
467
459
|
def unzip
|
468
460
|
warn "Method 'unzip' is not implemented yet." if $VERBOSE
|
469
461
|
return []
|
470
462
|
end
|
471
463
|
|
472
|
-
#
|
464
|
+
# unzip3
|
473
465
|
def unzip3
|
474
466
|
warn "Method 'unzip3' is not implemented yet." if $VERBOSE
|
475
467
|
return []
|
476
468
|
end
|
477
469
|
|
478
|
-
#
|
470
|
+
# unzip4, unzip5, unzip6, unzip7
|
479
471
|
def unzip4
|
480
472
|
warn "Method 'unzip4' is not implemented yet." if $VERBOSE
|
481
473
|
return []
|
482
474
|
end
|
483
475
|
|
484
476
|
|
485
|
-
#
|
477
|
+
# -- * Special lists
|
486
478
|
|
487
479
|
# -- ** Functions on strings
|
488
|
-
|
480
|
+
|
481
|
+
# lines -- :: String -> [String]
|
489
482
|
def lines
|
490
483
|
warn "Method 'lines' is not implemented yet." if $VERBOSE
|
491
484
|
return []
|
492
485
|
end
|
493
486
|
|
494
|
-
#
|
487
|
+
# words -- :: String -> [String]
|
495
488
|
def words
|
496
489
|
warn "Method 'words' is not implemented yet." if $VERBOSE
|
497
490
|
return []
|
498
491
|
end
|
499
492
|
|
500
|
-
#
|
493
|
+
# unlines -- :: [String] -> String
|
501
494
|
def unlines
|
502
495
|
warn "Method 'unlines' is not implemented yet." if $VERBOSE
|
503
496
|
return []
|
504
497
|
end
|
505
498
|
|
506
|
-
#
|
499
|
+
# unwords -- :: [String] -> String
|
507
500
|
def unwords
|
508
501
|
warn "Method 'unwords' is not implemented yet." if $VERBOSE
|
509
502
|
return []
|
@@ -512,44 +505,35 @@ module Prelude
|
|
512
505
|
|
513
506
|
# -- ** \"Set\" operations
|
514
507
|
|
515
|
-
#
|
508
|
+
# nub -- :: (Eq a) => [a] -> [a]
|
516
509
|
def nub
|
517
510
|
warn "Method 'nub' is not implemented yet." if $VERBOSE
|
518
511
|
return []
|
519
512
|
end
|
520
513
|
|
521
|
-
|
522
|
-
# , delete -- :: (Eq a) => a -> [a] -> [a]
|
514
|
+
# delete -- :: (Eq a) => a -> [a] -> [a]
|
523
515
|
# Implemented by Array but semantics is different
|
524
516
|
def delete(o)
|
525
517
|
warn "Method 'delete' is not implemented yet." if $VERBOSE
|
526
518
|
return []
|
527
519
|
end
|
528
|
-
|
529
520
|
|
530
|
-
#
|
531
|
-
# Don't know how to implement it in Ruby
|
532
|
-
|
533
|
-
|
534
|
-
# , union -- :: (Eq a) => [a] -> [a] -> [a]
|
521
|
+
# union -- :: (Eq a) => [a] -> [a] -> [a]
|
535
522
|
def union
|
536
523
|
warn "Method 'union' is not implemented yet." if $VERBOSE
|
537
524
|
return []
|
538
525
|
end
|
539
526
|
|
540
|
-
#
|
527
|
+
# intersect -- :: (Eq a) => [a] -> [a] -> [a]
|
541
528
|
def intersect
|
542
529
|
warn "Method 'intersect' is not implemented yet." if $VERBOSE
|
543
530
|
return []
|
544
531
|
end
|
545
532
|
|
546
|
-
|
547
533
|
# -- ** Ordered lists
|
548
|
-
# , sort -- :: (Ord a) => [a] -> [a]
|
549
|
-
# Implemented by Array
|
550
534
|
|
551
|
-
# , insert -- :: (Ord a) => a -> [a] -> [a]
|
552
535
|
# Implemented by Array but semantics is different
|
536
|
+
# insert -- :: (Ord a) => a -> [a] -> [a]
|
553
537
|
def insert(o)
|
554
538
|
warn "Method 'insert' is not implemented yet." if $VERBOSE
|
555
539
|
return []
|