Semantics for RISC code
This commit is contained in:
@ -12,6 +12,34 @@ let rec powmod a d = function
|
||||
let b = (powmod a d (n / 2)) mod d in
|
||||
(((b * b) mod d) * (if n mod 2 = 0 then 1 else a)) mod d
|
||||
|
||||
let int_and a b =
|
||||
match (a>0, b>0) with
|
||||
true, true -> 1
|
||||
| _, _ -> 0
|
||||
|
||||
let int_or a b =
|
||||
match (a>0, b>0) with
|
||||
false, false -> 0
|
||||
| _, _ -> 1
|
||||
|
||||
let int_eq a b =
|
||||
if a = b then 1 else 0
|
||||
|
||||
let int_less a b =
|
||||
if a < b then 1 else 0
|
||||
|
||||
let int_less_eq a b =
|
||||
if a <= b then 1 else 0
|
||||
|
||||
let int_more a b =
|
||||
if a > b then 1 else 0
|
||||
|
||||
let int_more_eq a b =
|
||||
if a >= b then 1 else 0
|
||||
|
||||
let int_not a =
|
||||
if a > 0 then 0 else 1
|
||||
|
||||
let rec fromIntToString (alphabet: string) (x: int) : string =
|
||||
let base = String.length alphabet in
|
||||
if x < 0 then
|
||||
|
||||
Reference in New Issue
Block a user