mirror of
https://github.com/Noratrieb/idris-learning.git
synced 2026-01-15 21:45:01 +01:00
read chapter 3
This commit is contained in:
parent
940f03eb01
commit
c43a16ecde
2 changed files with 84 additions and 0 deletions
|
|
@ -13,3 +13,33 @@ invert False = True
|
|||
describeList : Show a => List a -> String
|
||||
describeList [] = "Empty"
|
||||
describeList (x :: xs) = "Non-empty (" ++ show x ++ "), tail = " ++ show xs
|
||||
|
||||
showList : Show a => List a -> String
|
||||
showList [] = "[]"
|
||||
showList (x :: xs) = "[" ++ show x ++ showListInner xs
|
||||
where
|
||||
showListInner : Show a => List a -> String
|
||||
showListInner [] = "]"
|
||||
showListInner (x :: xs) = ", " ++ show x ++ showListInner xs
|
||||
|
||||
allLengthsNoMap : List String -> List Nat
|
||||
allLengthsNoMap [] = []
|
||||
allLengthsNoMap (word :: words) = length word :: allLengthsNoMap words
|
||||
|
||||
xor : Bool -> Bool -> Bool
|
||||
xor False y = y
|
||||
xor True y = not y
|
||||
|
||||
isEven2 : Nat -> Bool
|
||||
isEven2 Z = True
|
||||
isEven2 (S k) = not (isEven2 k)
|
||||
|
||||
mutual
|
||||
isEven : Nat -> Bool
|
||||
isEven Z = True
|
||||
isEven (S k) = isOdd k
|
||||
isOdd : Nat -> Bool
|
||||
isOdd Z = False
|
||||
isOdd (S k) = isEven k
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue