This repository has been archived by the owner on Feb 13, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pascalwoerde
committed
Oct 11, 2013
1 parent
a695c94
commit 1355608
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Flipper | ||
|
||
import StdEnv | ||
|
||
//Start = ( (+) 4 2, flip (+) 4 2 )// 6,6 | ||
//Start = ( (-) 4 2, flip (-) 4 2 ) // 2, -2 | ||
//Start = ( (*) 4 2, flip (*) 4 2 ) // 8, 8 | ||
//Start = ( (/) 4 2, flip (/) 4 2 ) // 2, 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Origami | ||
|
||
import StdEnv | ||
|
||
sum` :: [Int] -> Int | ||
sum` x = foldr (+) 0 x | ||
|
||
prod` :: [Int] -> Int | ||
prod` x = foldr (*) 1 x | ||
|
||
flatten` :: [[a]] -> [a] | ||
flatten` x = foldr (++) [] x | ||
|
||
length` :: [a] -> Int | ||
length` x = foldr (\_ n = n + 1) 0 x | ||
|
||
reverse` :: [a] -> [a] | ||
reverse` a = foldl (\xs x = [x] ++ xs) [] a | ||
|
||
takeWhile` :: (a -> Bool) [a] -> [a] | ||
takeWhile` a b = foldr (\x xs = if (a x) [x:xs] []) [] b | ||
|
||
maxList` :: [a] -> a | Ord a | ||
maxList` x = foldr max (hd x) x | ||
|
||
Start = and | ||
[ sum` [1 .. 5] == sum [1 .. 5] | ||
, prod` [1 .. 5] == prod [1 .. 5] | ||
, flatten` [[],[1],[1,2],[1,2,3]] == flatten [[],[1],[1,2],[1,2,3]] | ||
, length` [1 .. 5] == length [1 .. 5] | ||
, reverse` [1 .. 5] == reverse [1 .. 5] | ||
, takeWhile` ((<>) 0) [1,2,3,0,4,5,6] == takeWhile ((<>) 0) [1,2,3,0,4,5,6] | ||
, maxList` [1 .. 5] == maxList [1 .. 5] | ||
] |