mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-11-15 01:25:05 +03:00
17c7240825
+ Tutorial is now developed in a separate github repo. + Moved examples to top-level + Added binary of tutorial for v0.9.10
21 lines
474 B
Idris
21 lines
474 B
Idris
|
|
intVec : Vect 5 Int
|
|
intVec = [1, 2, 3, 4, 5]
|
|
|
|
double : Int -> Int
|
|
double x = x * 2
|
|
|
|
vec : (n ** Vect n Int)
|
|
vec = (_ ** [3, 4])
|
|
|
|
list_lookup : Nat -> List a -> Maybe a
|
|
list_lookup _ Nil = Nothing
|
|
list_lookup Z (x :: xs) = Just x
|
|
list_lookup (S k) (x :: xs) = list_lookup k xs
|
|
|
|
lookup_default : Nat -> List a -> a -> a
|
|
lookup_default i xs def = case list_lookup i xs of
|
|
Nothing => def
|
|
Just x => x
|
|
|