2024-05-18 18:01:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Two's complement Signed Integers
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
export {
|
|
|
|
|
let int-sign = λx:ℤ~machine.Int64 ↦ bit-and (bit-shr x 63) 1;
|
|
|
|
|
let int-neg = λx:ℤ~machine.Int64 ↦ i+ (bit-neg x) 1;
|
|
|
|
|
let int-abs = λx:ℤ~machine.Int64 ↦ if( int-sign x ) { int-neg x; } else { x; };
|
|
|
|
|
let int-lt = λ{ a:ℤ~machine.Int64; b:ℤ~machine.Int64; } ↦ int-sign (i- a b);
|
|
|
|
|
let int-gt = λ{ a:ℤ~machine.Int64; b:ℤ~machine.Int64; } ↦ int-sign (i- b a);
|
|
|
|
|
let int-eq = λ{ a:ℤ~machine.Int64; b:ℤ~machine.Int64; } ↦ if (bit-xor a b) { 0; } else { 1; };
|
|
|
|
|
let int-lte = λ{ a:ℤ~machine.Int64; b:ℤ~machine.Int64; } ↦ bit-or (int-lt a b) (int-eq a b);
|
|
|
|
|
let int-gte = λ{ a:ℤ~machine.Int64; b:ℤ~machine.Int64; } ↦ bit-or (int-gt a b) (int-eq a b);
|
|
|
|
|
let int-min = λ{ a:ℤ~machine.Int64; b:ℤ~machine.Int64; } ↦ if( int-lt a b ) { a; } else { b; };
|
|
|
|
|
let int-max = λ{ a:ℤ~machine.Int64; b:ℤ~machine.Int64; } ↦ if( int-gt a b ) { a; } else { b; };
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-11 15:17:58 +02:00
|
|
|
|
|
|
|
|
|
/* syntax ambiguity */
|
|
|
|
|
|
|
|
|
|
let f'0 = λx:A -> B ↦ { ... };
|
|
|
|
|
|
|
|
|
|
/* could be interpreted as .. */
|
|
|
|
|
let f'1 = λ{x: A -> B} ↦ {};
|
|
|
|
|
/* ..or.. */
|
|
|
|
|
let f'2 = λx:A ↦ B:{};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
!a 10;
|
|
|
|
|
!b 20;
|
|
|
|
|
}
|
|
|
|
|
|