Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nicola Botta
IdrisLibs2
Commits
bea35f62
Commit
bea35f62
authored
Aug 07, 2019
by
Nicola Botta
Browse files
Cleanup.
parent
ea549da3
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/Linear.idr
View file @
bea35f62
...
...
@@ -9,10 +9,15 @@ toVectFun {n = Z} _ = Nil
toVectFun
{
n
=
S
m
}
f
=
(
f
FZ
)
::
(
toVectFun
(
tail
f
))
N :
Nat
N
=
32
0
N
=
80
0
xs :
Vect
(
S
N
)
Nat
xs
=
toVectFun
{
n
=
S
N
}
finToNat
fromNat :
{
n
:
Nat
}
->
Nat
->
Fin
n
fromNat
{
n
=
S
m
}
Z
=
FZ
fromNat
{
n
=
S
m
}
(
S
i
)
=
if
i
<
m
then
FS
(
fromNat
i
)
else
last
main :
IO
()
main
=
putStrLn
(
"xs("
++
show
N
++
") = "
++
show
(
index
(
fromInteger
(
natToInteger
N
))
xs
))
-- main = putStrLn ("xs(" ++ show N ++ ") = " ++ show (index (fromNat N) xs))
tests/Linear.lidr
View file @
bea35f62
...
...
@@ -9,11 +9,15 @@
> toVectFun {n = S m} f = (f FZ) :: (toVectFun (tail f))
> N : Nat
> N =
16
00
> N =
8
00
> xs : Vect (S N) Nat
> xs = toVectFun {n = S N} finToNat
> fromNat : {n : Nat} -> Nat -> Fin n
> fromNat {n = S m} Z = FZ
> fromNat {n = S m} (S i) = if i < m then FS (fromNat i) else last
> main : IO ()
> main = putStrLn ("xs(" ++ show N ++ ") = " ++ show (index (fromInteger (toIntegerNat N)) xs))
> -- main = putStrLn ("xs(" ++ show N ++ ") = " ++ show (index (fromNat N) xs))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment