on master help sign in
skid
commitca3360e627b7443ce065e0a6af51422180420815 authoriko <mail@iko.soy> dateFri 23 Aug 2024, 16:42 (2 years ago) parent60cc51b
2 files changed+22
nock/src/jets.rs+14 nock/src/noun.rs+8
nock/src/jets.rs+14
@@ -46,6 +46,7 @@ pub fn generate_jets() -> Jets {
4646 (146282575960509029931248602154898675358, REEL),
4747 (218516926094890651045754335042357820192, ROLL),
4848 (89970054366691388746503743197917964564, SCAG),
49+ (68845187332605602565057027619381114427, SKID),
4950 ])
5051}
5152
@@ -367,3 +368,16 @@ static SCAG: Jet = |_ctx, n| {
367368 .map(|x| x.clone()),
368369 )
369370};
371+
372+static SKID: Jet = |ctx, n| {
373+ let (list, gate) = n.as_cell().unwrap();
374+
375+ let (ys, ns): (Vec<Rc<Noun>>, _) = list
376+ .list_iter()
377+ .partition(|n| slam(ctx, gate.clone(), n.clone()).is_y());
378+
379+ cell(
380+ Noun::list_refs(ys.iter().cloned()),
381+ Noun::list_refs(ns.iter().cloned()),
382+ )
383+};
nock/src/noun.rs+8
@@ -96,6 +96,14 @@ impl Noun {
9696 }
9797 }
9898
99+ pub fn is_y(self: &Self) -> bool {
100+ self.is_sig()
101+ }
102+
103+ pub fn is_n(self: &Self) -> bool {
104+ !self.is_sig()
105+ }
106+
99107 pub fn list_iter(self: Rc<Self>) -> NounListIterator {
100108 NounListIterator { noun: self.clone() }
101109 }