mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-20 10:02:03 +03:00
bf87b623ef
* add `scanr` and `scanr1` for `Vect` * add tests * tests * docstring * typos * add unsnoc * simplify unsnoc * docstring * typos
36 lines
718 B
Idris
36 lines
718 B
Idris
import Data.Vect
|
|
|
|
takeFromStream : List (n ** Vect n Int)
|
|
takeFromStream = [(n ** take n [3..]) | n <- [0, 1, 5]]
|
|
|
|
unsnocCases : List (n ** (Vect n Nat, Nat))
|
|
unsnocCases = [
|
|
(_ ** unsnoc [3])
|
|
, (_ ** unsnoc [3, 4])
|
|
, (_ ** unsnoc [3, 4, 5])
|
|
]
|
|
|
|
scanrMul : List (n ** Vect n Nat)
|
|
scanrMul = [
|
|
(_ ** scanr (*) 2 [])
|
|
, (_ ** scanr (*) 2 [3])
|
|
, (_ ** scanr (*) 2 [5, 4, 3])
|
|
]
|
|
|
|
scanrCons : Vect 4 (List Nat)
|
|
scanrCons = scanr (::) Nil [2, 3, 4]
|
|
|
|
scanr1Mul : List (n ** Vect n Nat)
|
|
scanr1Mul = [
|
|
(_ ** scanr1 (*) [3])
|
|
, (_ ** scanr1 (*) [5, 4, 3])
|
|
]
|
|
|
|
main : IO ()
|
|
main = do
|
|
printLn takeFromStream
|
|
printLn unsnocCases
|
|
printLn scanrMul
|
|
printLn scanrCons
|
|
printLn scanr1Mul
|