on master help sign in
murn
commit32dbe2da6a2b47e2d4d64c854e3ffa0459ce258f authoriko <mail@iko.soy> dateThu 22 Aug 2024, 13:22 (2 years ago) parent7d850b9
2 files changed+22
nock/src/jets.rs+13 nock/src/noun.rs+9
nock/src/jets.rs+13
@@ -40,6 +40,7 @@ pub fn generate_jets() -> Jets {
4040 (211253539934007667533839299235896640130, LENT),
4141 (104838119266193725126177792605193739824, LEVY),
4242 (136665047491594821996133547576675424469, LIEN),
43+ (134383540064775397895881415210519251023, MURN),
4344 ])
4445}
4546
@@ -311,3 +312,15 @@ static LIEN: Jet = |ctx, n| {
311312 ctx.nouns.n.clone()
312313 }
313314};
315+
316+static MURN: Jet = |ctx, n| {
317+ let (a, b) = n.as_cell().unwrap();
318+
319+ Noun::list_refs(
320+ a.list_iter()
321+ .filter_map(|n| call_gate(ctx, b.clone(), n).as_unit())
322+ .collect::<Vec<_>>()
323+ .iter()
324+ .map(|x| x.clone()),
325+ )
326+};
nock/src/noun.rs+9
@@ -83,6 +83,15 @@ impl Noun {
8383 NounListIterator { noun: self.clone() }
8484 }
8585
86+ /// panics if malformed
87+ pub fn as_unit(self: &Self) -> Option<Rc<Self>> {
88+ if self.is_sig() {
89+ Option::None
90+ } else {
91+ Option::Some(self.as_cell().unwrap().1)
92+ }
93+ }
94+
8695 pub fn hash(self: &Self) -> Hash {
8796 match self {
8897 Noun::Cell { hash, .. } => *hash,