prelude 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,39 @@
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 program is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation; either version 2 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program 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
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License along
20
+ # with this program; if not, write to the Free Software Foundation, Inc.,
21
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
+ #++
23
+
24
+ module Prelude
25
+
26
+ # $Id: monad.rb 2 2006-08-25 00:11:17Z prelude $
27
+ #
28
+ # Monad implementation is inspired by the following sources:
29
+ #
30
+ # * article "Late to the Party" posted at http://cwilliams.textdriven.com/pages/monads, I could not detect
31
+ # the author's name
32
+ # * writings by MenTaLguY, see http://moonbase.rydia.net/mental/writings/programming/monads-in-ruby/00introduction.html
33
+ #
34
+ class Monad
35
+ def bind(&block)
36
+ collect(&block).flatten
37
+ end
38
+ end # Monad
39
+ end # Prelude
@@ -0,0 +1,64 @@
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 program is free software; you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation; either version 2 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program 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
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License along
20
+ # with this program; if not, write to the Free Software Foundation, Inc.,
21
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
+ #++
23
+
24
+ module Prelude
25
+
26
+ # $Id: tuple.rb 2 2006-08-25 00:11:17Z prelude $
27
+ #
28
+ class Tuple < Array
29
+
30
+ def new(*args)
31
+ case
32
+ when args.nil? || args.empty? :
33
+ super.new([nil, nil])
34
+ when args.lengh == 1 && args[0].kind_of(Array) :
35
+ super.new(args[0][0])
36
+ self << super.new([args[0][1..-1]])
37
+ when args.lengh == 1 :
38
+ super.new([args[0], nil])
39
+ when args.lengh == 2 :
40
+ super.new(args)
41
+ when args.lengh > 2 :
42
+ super.new([args[0], args[1..-1]])
43
+ end # case
44
+ end
45
+
46
+ def fst
47
+ self[0]
48
+ end
49
+
50
+ def snd
51
+ self[1]
52
+ end
53
+
54
+ def fst=(o)
55
+ self[0] = o
56
+ end
57
+
58
+ def snd=(o)
59
+ self[1] = o
60
+ end
61
+
62
+ end # Tuple
63
+
64
+ end # Prelude
@@ -0,0 +1,89 @@
1
+ #--
2
+ # $Id: tc_higher.rb 1 2006-08-24 20:34:21Z prelude $
3
+ #
4
+ #
5
+ # This file is part of the Prelude library that provides tools to
6
+ # enable Haskell style functional programming in Ruby.
7
+ #
8
+ # http://prelude.rubyforge.org
9
+ #
10
+ # Copyright (C) 2006 APP Design, Inc.
11
+ #
12
+ # This program is free software; you can redistribute it and/or modify
13
+ # it under the terms of the GNU General Public License as published by
14
+ # the Free Software Foundation; either version 2 of the License, or
15
+ # (at your option) any later version.
16
+ #
17
+ # This program is distributed in the hope that it will be useful,
18
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ # GNU General Public License for more details.
21
+ #
22
+ # You should have received a copy of the GNU General Public License along
23
+ # with this program; if not, write to the Free Software Foundation, Inc.,
24
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
+ #++
26
+
27
+ class TestHigher < Test::Unit::TestCase
28
+
29
+ def setup
30
+ # Nothing
31
+ end # setup
32
+
33
+ def teardown
34
+ # Nothing
35
+ end # teardown
36
+
37
+ #
38
+ # Test higher functions
39
+ #
40
+ def test_curry_proc
41
+ add5 = (proc {|x,y,z| x+y+z}).curry(5)
42
+
43
+ result = add5[3, 2]
44
+ expect = 10
45
+
46
+ assert_equal(expect, result)
47
+
48
+ result = add5.call(3, 2)
49
+ expect = 10
50
+
51
+ assert_equal(expect, result)
52
+ end
53
+
54
+ def test_curry_symbol
55
+ add5 = :+.curry(5)
56
+
57
+ result = add5.call(3)
58
+ expect = 8
59
+
60
+ assert_equal(expect, result)
61
+
62
+ result = add5[4]
63
+ expect = 9
64
+
65
+ assert_equal(expect, result)
66
+ end
67
+
68
+ def test_stream
69
+ add5 = proc {|x| x+5}
70
+ add6 = proc {|x,y| x+y+6}
71
+ add11 = add5 << add6
72
+
73
+ result = add11[1, 2]
74
+ expect = 14
75
+
76
+ assert_equal(expect, result)
77
+
78
+ result = add5 << 1
79
+ expect = 6
80
+
81
+ assert_equal(expect, result)
82
+
83
+ result = add5 << add6 << [1, 2]
84
+ expect = 14
85
+
86
+ assert_equal(expect, result)
87
+ end
88
+
89
+ end # TestHigher
@@ -0,0 +1,772 @@
1
+ #--
2
+ # $Id: tc_list.rb 1 2006-08-24 20:34:21Z prelude $
3
+ #
4
+ #
5
+ # This file is part of the Prelude library that provides tools to
6
+ # enable Haskell style functional programming in Ruby.
7
+ #
8
+ # http://prelude.rubyforge.org
9
+ #
10
+ # Copyright (C) 2006 APP Design, Inc.
11
+ #
12
+ # This program is free software; you can redistribute it and/or modify
13
+ # it under the terms of the GNU General Public License as published by
14
+ # the Free Software Foundation; either version 2 of the License, or
15
+ # (at your option) any later version.
16
+ #
17
+ # This program is distributed in the hope that it will be useful,
18
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ # GNU General Public License for more details.
21
+ #
22
+ # You should have received a copy of the GNU General Public License along
23
+ # with this program; if not, write to the Free Software Foundation, Inc.,
24
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
+ #++
26
+
27
+ class TestList < Test::Unit::TestCase
28
+
29
+ def setup
30
+
31
+ @a = List.new([1, 2, 3, 4, 5])
32
+ @true_list = List.new([true, true, true])
33
+ @false_list = List.new([false, false, false])
34
+ @mixed_list = List.new([false, true, false])
35
+
36
+ end # setup
37
+
38
+ def teardown
39
+ # Nothing
40
+ end # teardown
41
+
42
+ def test_head
43
+ result = @a.head
44
+ expect = 1
45
+
46
+ assert_equal(expect, result)
47
+ end
48
+
49
+ # Compatibility with the Array class
50
+ def test_array_plus
51
+ b = [6, 7]
52
+
53
+ result = @a+b
54
+ expect = [1, 2, 3, 4, 5, 6, 7]
55
+
56
+ assert_instance_of(List, result)
57
+ assert_equal(expect, result)
58
+ end
59
+
60
+ def test_array_assignment
61
+ @a[1] = 10
62
+ result = @a
63
+ expect = [1, 10, 3, 4, 5]
64
+
65
+ assert_instance_of(List, result)
66
+ assert_equal(expect, result)
67
+ end
68
+
69
+ def test_array_shift
70
+ result = @a << 100 << 101
71
+ expect = [1, 2, 3, 4, 5, 100, 101]
72
+
73
+ assert_instance_of(List, result)
74
+ assert_equal(expect, result)
75
+ end
76
+
77
+ # , last -- :: [a] -> a
78
+ def test_last
79
+ result = @a.last
80
+ expect = 5
81
+
82
+ assert_equal(expect, result)
83
+ end
84
+
85
+ # , tail -- :: [a] -> [a]
86
+ def test_tail
87
+ result = @a.tail
88
+ expect = [2, 3, 4, 5]
89
+
90
+ assert_equal(expect, result)
91
+ end
92
+
93
+ # , init -- :: [a] -> [a]
94
+ def test_init
95
+ result = @a.init
96
+ expect = [1, 2, 3, 4]
97
+
98
+ assert_equal(expect, result)
99
+ end
100
+
101
+ # , null -- :: [a] -> Bool
102
+ def test_null
103
+ result = @a.null
104
+ expect = false
105
+
106
+ assert_equal(expect, result)
107
+ end
108
+
109
+ # , length -- :: [a] -> Int
110
+ def test_length
111
+ result = @a.length
112
+ expect = 5
113
+
114
+ assert_equal(expect, result)
115
+ end
116
+
117
+
118
+ # -- * List transformations
119
+ # , map -- :: (a -> b) -> [a] -> [b]
120
+ # already defined by the Array
121
+
122
+ # , reverse -- :: [a] -> [a]
123
+ # already defined by the Array
124
+
125
+ # , intersperse -- :: a -> [a] -> [a]
126
+ def test_intersperse
127
+ result = @a.intersperse
128
+ expect = []
129
+
130
+ assert_equal(expect, result)
131
+ end
132
+
133
+ # , transpose -- :: [[a]] -> [[a]]
134
+ def test_transpose
135
+ result = List.new([@a, @a, @a]).transpose
136
+ expect = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5] ]
137
+
138
+ assert_equal(expect, result)
139
+ end
140
+
141
+ # -- * Reducing lists (folds)
142
+
143
+ # , foldl -- :: (a -> b -> a) -> a -> [b] -> a
144
+
145
+ # Classic recursive functional definition causes stack overflow for
146
+ # arrays of any usable size... So don't use it, it's here for completeness
147
+ def test_f_foldl
148
+ result = @a.f_foldl(0){ |x, y| x+y}
149
+ expect = 15
150
+
151
+ assert_equal(expect, result)
152
+ end
153
+
154
+ # This is a more pedestrian iterative version.
155
+ def test_foldl
156
+ result = @a.foldl(0){ |x, y| x+y}
157
+ expect = 15
158
+
159
+ assert_equal(expect, result)
160
+ end
161
+
162
+ # , foldl' -- :: (a -> b -> a) -> a -> [b] -> a
163
+ def test_foldl_
164
+ result = @a.foldl_
165
+ expect = []
166
+
167
+ assert_equal(expect, result)
168
+ end
169
+
170
+ # , foldl1 -- :: (a -> a -> a) -> [a] -> a
171
+ def test_foldl1
172
+ result = @a.foldl1{ |x, y| x*y}
173
+ expect = 120
174
+
175
+ assert_equal(expect, result)
176
+ end
177
+
178
+ # , foldl1' -- :: (a -> a -> a) -> [a] -> a
179
+ def test_foldl1_
180
+ result = @a.foldl1_
181
+ expect = []
182
+
183
+ assert_equal(expect, result)
184
+ end
185
+
186
+ # , foldr -- :: (a -> b -> b) -> b -> [a] -> b
187
+ def test_foldr
188
+ result = @a.foldr(0){ |x, y| x+y}
189
+ expect = 15
190
+
191
+ assert_equal(expect, result)
192
+ end
193
+
194
+ # , foldr1 -- :: (a -> a -> a) -> [a] -> a
195
+ def test_foldr1
196
+ result = @a.foldr1{ |x, y| x*y}
197
+ expect = 120
198
+
199
+ assert_equal(expect, result)
200
+ end
201
+
202
+ # -- ** Special folds
203
+
204
+ # , concat -- :: [[a]] -> [a]
205
+ def test_concat
206
+ result = List.new([@a, [@a]]).concat
207
+ expect = @a+@a
208
+
209
+ assert_equal(expect, result)
210
+ end
211
+
212
+ # , concatMap -- :: (a -> [b]) -> [a] -> [b]
213
+ def test_concatMap
214
+ result = @a.concatMap
215
+ expect = []
216
+
217
+ assert_equal(expect, result)
218
+ end
219
+
220
+ # , and -- :: [Bool] -> Bool
221
+ def test_and
222
+ result = @true_list.and
223
+ expect = true
224
+
225
+ assert_equal(expect, result)
226
+
227
+ result = @mixed_list.and
228
+ expect = false
229
+
230
+ assert_equal(expect, result)
231
+
232
+ result = @false_list.and
233
+ expect = false
234
+
235
+ assert_equal(expect, result)
236
+ end
237
+
238
+ # , or -- :: [Bool] -> Bool
239
+ def test_or
240
+ result = @true_list.or
241
+ expect = true
242
+
243
+ assert_equal(expect, result)
244
+
245
+ result = @mixed_list.or
246
+ expect = true
247
+
248
+ assert_equal(expect, result)
249
+
250
+ result = @false_list.or
251
+ expect = false
252
+
253
+ assert_equal(expect, result)
254
+ end
255
+
256
+ # , any -- :: (a -> Bool) -> [a] -> Bool
257
+ def test_any
258
+ result = @a.any{|x| x>5}
259
+ expect = false
260
+
261
+ assert_equal(expect, result)
262
+
263
+ result = @a.any{|x| x<5}
264
+ expect = true
265
+
266
+ assert_equal(expect, result)
267
+ end
268
+
269
+ # , all -- :: (a -> Bool) -> [a] -> Bool
270
+ def test_all
271
+ result = @a.all{|x| x>3}
272
+ expect = false
273
+
274
+ assert_equal(expect, result)
275
+
276
+ result = @a.all{|x| x>0}
277
+ expect = true
278
+
279
+ assert_equal(expect, result)
280
+ end
281
+
282
+ # , sum -- :: (Num a) => [a] -> a
283
+ def test_sum
284
+ result = @a.sum
285
+ expect = []
286
+
287
+ assert_equal(expect, result)
288
+ end
289
+
290
+ # , product -- :: (Num a) => [a] -> a
291
+ def test_product
292
+ result = @a.product
293
+ expect = []
294
+
295
+ assert_equal(expect, result)
296
+ end
297
+
298
+ # , maximum -- :: (Ord a) => [a] -> a
299
+ def test_maximum
300
+ result = @a.maximum
301
+ expect = []
302
+
303
+ assert_equal(expect, result)
304
+ end
305
+
306
+ # , minimum -- :: (Ord a) => [a] -> a
307
+ def test_minimum
308
+ result = @a.minimum
309
+ expect = []
310
+
311
+ assert_equal(expect, result)
312
+ end
313
+
314
+
315
+ # -- * Building lists
316
+
317
+ # -- ** Scans
318
+ # , scanl -- :: (a -> b -> a) -> a -> [b] -> [a]
319
+ def test_scanl
320
+ result = @a.scanl(0){ |x, y| x+y}
321
+ expect = [0, 1, 3, 6, 10, 15]
322
+
323
+ assert_equal(expect, result)
324
+ end
325
+
326
+ # , scanl1 -- :: (a -> a -> a) -> [a] -> [a]
327
+ def test_scanl1
328
+ result = @a.scanl1{ |x, y| x+y}
329
+ expect = [1, 3, 6, 10, 15]
330
+
331
+ assert_equal(expect, result)
332
+ end
333
+
334
+ # , scanr -- :: (a -> b -> b) -> b -> [a] -> [b]
335
+ def test_scanr
336
+ result = @a.scanr(0){ |x, y| x+y}
337
+ expect = [0, 1, 3, 6, 10, 15]
338
+
339
+ assert_equal(expect, result)
340
+ end
341
+
342
+ # , scanr1 -- :: (a -> a -> a) -> [a] -> [a]
343
+ def test_scanr1
344
+ result = @a.scanr1{ |x, y| x+y}
345
+ expect = [1, 3, 6, 10, 15]
346
+
347
+ assert_equal(expect, result)
348
+ end
349
+
350
+
351
+ # -- ** Accumulating maps
352
+ # , mapAccumL -- :: (a -> b -> (a,c)) -> a -> [b] -> (a,[c])
353
+ def test_mapAccumL
354
+ result = @a.mapAccumL
355
+ expect = []
356
+
357
+ assert_equal(expect, result)
358
+ end
359
+
360
+ # , mapAccumR -- :: (a -> b -> (a,c)) -> a -> [b] -> (a,[c])
361
+ def test_mapAccumR
362
+ result = @a.mapAccumR
363
+ expect = []
364
+
365
+ assert_equal(expect, result)
366
+ end
367
+
368
+
369
+ # -- ** Infinite lists
370
+ # , iterate -- :: (a -> a) -> a -> [a]
371
+ def test_iterate
372
+ result = @a.iterate
373
+ expect = []
374
+
375
+ assert_equal(expect, result)
376
+ end
377
+
378
+ # , repeat -- :: a -> [a]
379
+ def test_repeat
380
+ result = @a.repeat
381
+ expect = []
382
+
383
+ assert_equal(expect, result)
384
+ end
385
+
386
+ # , replicate -- :: Int -> a -> [a]
387
+ def test_replicate
388
+ result = @a.replicate
389
+ expect = []
390
+
391
+ assert_equal(expect, result)
392
+ end
393
+
394
+ # , cycle -- :: [a] -> [a]
395
+ def test_cycle
396
+ result = @a.cycle
397
+ expect = []
398
+
399
+ assert_equal(expect, result)
400
+ end
401
+
402
+
403
+ # -- ** Unfolding
404
+ # , unfoldr -- :: (b -> Maybe (a, b)) -> b -> [a]
405
+ def test_unfoldr
406
+ result = @a.unfoldr
407
+ expect = []
408
+
409
+ assert_equal(expect, result)
410
+ end
411
+
412
+
413
+ # -- * Sublists
414
+
415
+ # -- ** Extracting sublists
416
+ # , take -- :: Int -> [a] -> [a]
417
+ def test_take
418
+ result = @a.take(2)
419
+ expect = [1, 2]
420
+
421
+ assert_equal(expect, result)
422
+ end
423
+
424
+ # , drop -- :: Int -> [a] -> [a]
425
+ def test_drop
426
+ result = @a.drop(2)
427
+ expect = [3, 4, 5]
428
+
429
+ assert_equal(expect, result)
430
+ end
431
+
432
+ # , splitAt -- :: Int -> [a] -> ([a], [a])
433
+ def test_split_at
434
+ result = @a.split_at(2)
435
+ expect = [[1, 2],[3, 4, 5]]
436
+
437
+ assert_equal(expect, result)
438
+ end
439
+
440
+ # , takeWhile -- :: (a -> Bool) -> [a] -> [a]
441
+ def test_takeWhile
442
+ result = @a.takeWhile{|x| x<4}
443
+ expect = [1, 2, 3]
444
+
445
+ assert_equal(expect, result)
446
+ end
447
+
448
+ # , dropWhile -- :: (a -> Bool) -> [a] -> [a]
449
+ def test_dropWhile
450
+ result = @a.dropWhile{|x| x<4}
451
+ expect = [4, 5]
452
+
453
+ assert_equal(expect, result)
454
+ end
455
+
456
+ # , span -- :: (a -> Bool) -> [a] -> ([a], [a])
457
+ def test_span
458
+ result = @a.span{|x| x<3}
459
+ expect = [[1, 2], [3, 4, 5]]
460
+
461
+ assert_equal(expect, result)
462
+ end
463
+
464
+ # , break -- :: (a -> Bool) -> [a] -> ([a], [a])
465
+ def test_break
466
+ result = @a.break
467
+ expect = []
468
+
469
+ assert_equal(expect, result)
470
+ end
471
+
472
+ # , group -- :: Eq a => [a] -> [[a]]
473
+ def test_group
474
+ result = @a.group
475
+ expect = []
476
+
477
+ assert_equal(expect, result)
478
+ end
479
+
480
+ # , inits -- :: [a] -> [[a]]
481
+ def test_inits
482
+ result = @a.inits
483
+ expect = []
484
+
485
+ assert_equal(expect, result)
486
+ end
487
+
488
+ # , tails -- :: [a] -> [[a]]
489
+ def test_tails
490
+ result = @a.tails
491
+ expect = []
492
+
493
+ assert_equal(expect, result)
494
+ end
495
+
496
+ # -- ** Predicates
497
+ # , isPrefixOf -- :: (Eq a) => [a] -> [a] -> Bool
498
+ def test_isPrefixOf
499
+ result = @a.isPrefixOf
500
+ expect = []
501
+
502
+ assert_equal(expect, result)
503
+ end
504
+
505
+ # , isSuffixOf -- :: (Eq a) => [a] -> [a] -> Bool
506
+ def test_isSuffixOf
507
+ result = @a.isSuffixOf
508
+ expect = []
509
+
510
+ assert_equal(expect, result)
511
+ end
512
+
513
+
514
+ # -- * Searching lists
515
+
516
+ # -- ** Searching by equality
517
+ # , elem -- :: a -> [a] -> Bool
518
+ def test_elem
519
+ result = @a.elem
520
+ expect = []
521
+
522
+ assert_equal(expect, result)
523
+ end
524
+
525
+ # , notElem -- :: a -> [a] -> Bool
526
+ def test_notElem
527
+ result = @a.notElem
528
+ expect = []
529
+
530
+ assert_equal(expect, result)
531
+ end
532
+
533
+ # , lookup -- :: (Eq a) => a -> [(a,b)] -> Maybe b
534
+ def test_lookup
535
+ result = @a.lookup
536
+ expect = []
537
+
538
+ assert_equal(expect, result)
539
+ end
540
+
541
+ # -- ** Searching with a predicate
542
+ # , find -- :: (a -> Bool) -> [a] -> Maybe a
543
+ def test_find
544
+ result = @a.find{|x| x==3}
545
+ expect = 3
546
+
547
+ assert_equal(expect, result)
548
+ end
549
+
550
+ # , filter -- :: (a -> Bool) -> [a] -> [a]
551
+ def test_filter
552
+ result = @a.filter
553
+ expect = []
554
+
555
+ assert_equal(expect, result)
556
+ end
557
+
558
+ # , partition -- :: (a -> Bool) -> [a] -> ([a], [a])
559
+ def test_partition
560
+ result = @a.partition{|x| x>3}
561
+ expect = [[4, 5], [1, 2, 3]]
562
+
563
+ assert_equal(expect, result)
564
+ end
565
+
566
+
567
+ # -- * Indexing lists
568
+ # -- | These functions treat a list @xs@ as a indexed collection,
569
+ # -- with indices ranging from 0 to @'length' xs - 1@.
570
+
571
+ # , (!!) -- :: [a] -> Int -> a
572
+ # Don't know how to implement it in Ruby
573
+
574
+
575
+ # , elemIndex -- :: (Eq a) => a -> [a] -> Maybe Int
576
+ def test_elemIndex
577
+ result = @a.elemIndex
578
+ expect = []
579
+
580
+ assert_equal(expect, result)
581
+ end
582
+
583
+ # , elemIndices -- :: (Eq a) => a -> [a] -> [Int]
584
+ def test_elemIndices
585
+ result = @a.elemIndices
586
+ expect = []
587
+
588
+ assert_equal(expect, result)
589
+ end
590
+
591
+
592
+ # , findIndex -- :: (a -> Bool) -> [a] -> Maybe Int
593
+ def test_findIndex
594
+ result = @a.findIndex
595
+ expect = []
596
+
597
+ assert_equal(expect, result)
598
+ end
599
+
600
+ # , findIndices -- :: (a -> Bool) -> [a] -> [Int]
601
+ def test_findIndices
602
+ result = @a.findIndices
603
+ expect = []
604
+
605
+ assert_equal(expect, result)
606
+ end
607
+
608
+
609
+ # -- * Zipping and unzipping lists
610
+
611
+ # , zip -- :: [a] -> [b] -> [(a,b)]
612
+ def test_zip
613
+ result = @a.zip(@a)
614
+ expect = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5] ]
615
+
616
+ assert_equal(expect, result)
617
+ end
618
+
619
+ # , zip3
620
+ def test_zip3
621
+ result = @a.zip3
622
+ expect = []
623
+
624
+ assert_equal(expect, result)
625
+ end
626
+
627
+ # , zip4, zip5, zip6, zip7
628
+ def test_zip4
629
+ result = @a.zip4
630
+ expect = []
631
+
632
+ assert_equal(expect, result)
633
+ end
634
+
635
+
636
+ # , zipWith -- :: (a -> b -> c) -> [a] -> [b] -> [c]
637
+ def test_zipWith
638
+ result = @a.zipWith
639
+ expect = []
640
+
641
+ assert_equal(expect, result)
642
+ end
643
+
644
+ # , zipWith3
645
+ def test_zipWith3
646
+ result = @a.zipWith3
647
+ expect = []
648
+
649
+ assert_equal(expect, result)
650
+ end
651
+
652
+ # , zipWith4, zipWith5, zipWith6, zipWith7
653
+ def test_zipWith4
654
+ result = @a.zipWith4
655
+ expect = []
656
+
657
+ assert_equal(expect, result)
658
+ end
659
+
660
+
661
+ # , unzip -- :: [(a,b)] -> ([a],[b])
662
+ def test_unzip
663
+ result = @a.unzip
664
+ expect = []
665
+
666
+ assert_equal(expect, result)
667
+ end
668
+
669
+ # , unzip3
670
+ def test_unzip3
671
+ result = @a.unzip3
672
+ expect = []
673
+
674
+ assert_equal(expect, result)
675
+ end
676
+
677
+ # , unzip4, unzip5, unzip6, unzip7
678
+ def test_unzip4
679
+ result = @a.unzip4
680
+ expect = []
681
+
682
+ assert_equal(expect, result)
683
+ end
684
+
685
+
686
+ # -- * Special lists
687
+
688
+ # -- ** Functions on strings
689
+ # , lines -- :: String -> [String]
690
+ def test_lines
691
+ result = @a.lines
692
+ expect = []
693
+
694
+ assert_equal(expect, result)
695
+ end
696
+
697
+ # , words -- :: String -> [String]
698
+ def test_words
699
+ result = @a.words
700
+ expect = []
701
+
702
+ assert_equal(expect, result)
703
+ end
704
+
705
+ # , unlines -- :: [String] -> String
706
+ def test_unlines
707
+ result = @a.unlines
708
+ expect = []
709
+
710
+ assert_equal(expect, result)
711
+ end
712
+
713
+ # , unwords -- :: [String] -> String
714
+ def test_unwords
715
+ result = @a.unwords
716
+ expect = []
717
+
718
+ assert_equal(expect, result)
719
+ end
720
+
721
+
722
+ # -- ** \"Set\" operations
723
+
724
+ # , nub -- :: (Eq a) => [a] -> [a]
725
+ def test_nub
726
+ result = @a.nub
727
+ expect = []
728
+
729
+ assert_equal(expect, result)
730
+ end
731
+
732
+
733
+ # , delete -- :: (Eq a) => a -> [a] -> [a]
734
+ def test_delete
735
+ result = @a.delete(3)
736
+ expect = []
737
+
738
+ assert_equal(expect, result)
739
+ end
740
+
741
+ # , (\\) -- :: (Eq a) => [a] -> [a] -> [a]
742
+ # Don't know how to implement it in Ruby
743
+
744
+ # , union -- :: (Eq a) => [a] -> [a] -> [a]
745
+ def test_union
746
+ result = @a.union
747
+ expect = []
748
+
749
+ assert_equal(expect, result)
750
+ end
751
+
752
+ # , intersect -- :: (Eq a) => [a] -> [a] -> [a]
753
+ def test_intersect
754
+ result = @a.intersect
755
+ expect = []
756
+
757
+ assert_equal(expect, result)
758
+ end
759
+
760
+
761
+ # -- ** Ordered lists
762
+ # , sort -- :: (Ord a) => [a] -> [a]
763
+
764
+ # , insert -- :: (Ord a) => a -> [a] -> [a]
765
+ def test_insert
766
+ result = @a.insert(3.5)
767
+ expect = []
768
+
769
+ assert_equal(expect, result)
770
+ end
771
+
772
+ end # TestList