mirror of
https://github.com/GaloisInc/cryptol.git
synced 2025-01-05 23:17:42 +03:00
Add function generate
to Cryptol prelude.
generate : {n, ix, a} (fin ix, n >= 1, ix >= width (n - 1)) => ([ix] -> a) -> [n]a generate f = [ f i | i <- [0 .. n-1] ]
This commit is contained in:
parent
ec7c9a0f6e
commit
2df66aa7c1
@ -492,6 +492,14 @@ primitive infFrom : {a} (Arith a) => a -> [inf]a
|
||||
*/
|
||||
primitive infFromThen : {a} (Arith a) => a -> a -> [inf]a
|
||||
|
||||
/**
|
||||
* Produce a sequence using a generating function.
|
||||
* Satisfies 'generate f @ i == f i' for all 'i' between '0' and 'n-1'.
|
||||
*/
|
||||
generate : {n, ix, a}
|
||||
(fin ix, n >= 1, ix >= width (n - 1)) => ([ix] -> a) -> [n]a
|
||||
generate f = [ f i | i <- [0 .. n-1] ]
|
||||
|
||||
primitive error : {a, len} (fin len) => [len][8] -> a
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user