1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-04 17:07:28 +03:00
juvix/tests/VampIR/positive/Core/test025.jvc
Łukasz Czajka 336a934d18
Normalization by Evaluation (#2038)
* Closes #2032.
* Adds the `juvix dev core normalize` command.
* Adds the `:n` command in JuvixCore REPL.
* Adds the `--normalize` flag to `juvix dev core read` and `juvix dev
core from-concrete`.
* Adds `pipeline-normalize` which denotes pipeline steps necessary
before normalization.
* Adds normalization tests in `tests/VampIR/positive/Core`.
2023-05-15 18:01:40 +02:00

16 lines
334 B
Plaintext

-- mid-square hashing
def pow : Int -> Int := \(x : Int) if x = 0 then 1 else 2 * pow (x - 1);
def hash' : Int -> Int -> Int := \(n : Int) \(x : Int)
if n <= 3 then
x * x
else if x < pow (n - 1) then
hash' (n - 1) x
else
((x * x) / pow (n - 3)) % pow 6;
def hash : Int -> Int := hash' 16;
hash