Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More lm to lsts 3 #1069

Merged
merged 8 commits into from
Jan 12, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cmp
andrew-johnson-4 committed Jan 12, 2025
commit 298a463bc9ca1edfcd896eaf7dd59b550738adc1
6 changes: 6 additions & 0 deletions PLATFORM/C/LIB/cmp.lsts
Original file line number Diff line number Diff line change
@@ -21,3 +21,9 @@ let $">"(l: x, r: x): U64 = cmp(l, r) > Equal;
let $">="(l: x, r: x): U64 = cmp(l, r) >= Equal;

let $"&&"(l: Ord, r: Ord): Ord = if is(l, Equal) then r else l;

let print(io: IO::File, o: Ord): Nil = (
if is(o,GreaterThan) then print(io, "GreaterThan") else
if is(o,Equal) then print(io, "Equal") else
print(io, "LessThan");
);
36 changes: 36 additions & 0 deletions tests/lib/cmp.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

import LIB/default.lm;

assert( LessThan == LessThan );
assert( LessThan != Equal );
assert( LessThan != GreaterThan );
assert( Equal != LessThan );
assert( Equal == Equal );
assert( Equal != GreaterThan );
assert( GreaterThan != LessThan );
assert( GreaterThan != Equal );
assert( GreaterThan == GreaterThan );

assert( LessThan < Equal );
assert( LessThan < GreaterThan );
assert( Equal < GreaterThan );

assert( LessThan <= LessThan );
assert( LessThan <= Equal );
assert( LessThan <= GreaterThan );
assert( Equal <= Equal );
assert( Equal <= GreaterThan );
assert( GreaterThan <= GreaterThan );

assert( GreaterThan > LessThan );
assert( GreaterThan > Equal );
assert( Equal > LessThan );

assert( GreaterThan >= LessThan );
assert( GreaterThan >= Equal );
assert( GreaterThan >= GreaterThan );
assert( Equal >= LessThan );
assert( Equal >= Equal );
assert( LessThan >= LessThan );

print("Success\n");