[jets] add gth jet

This commit is contained in:
Philip Monk 2023-02-13 22:46:29 -07:00
parent bbae5bb146
commit 9fb605769e
2 changed files with 27 additions and 0 deletions

View File

@ -36,6 +36,7 @@ pub fn get_jet(jet_name: Noun) -> Result<Jet, ()> {
tas!(b"mod") => Ok(jet_mod),
tas!(b"lth") => Ok(jet_lth),
tas!(b"lte") => Ok(jet_lte),
tas!(b"gth") => Ok(jet_gth),
tas!(b"cut") => Ok(jet_cut),
tas!(b"mug") => Ok(jet_mug),
_ => {

View File

@ -248,3 +248,29 @@ pub fn jet_lte(_stack: &mut NockStack, subject: Noun) -> Result<Noun, JetErr> {
}
})
}
pub fn jet_gth(_stack: &mut NockStack, subject: Noun) -> Result<Noun, JetErr> {
let arg = raw_slot(subject, 6);
let a = raw_slot(arg, 2).as_atom()?;
let b = raw_slot(arg, 3).as_atom()?;
Ok(if let (Ok(a), Ok(b)) = (a.as_direct(), b.as_direct()) {
if a.data() > b.data() {
YES
} else {
NO
}
} else {
if a.bit_size() > b.bit_size() {
YES
} else if a.bit_size() < b.bit_size() {
NO
} else {
if a.as_ubig() > b.as_ubig() {
YES
} else {
NO
}
}
})
}