on master help sign in
spin
commitc889775606777c04f95675c47839cb37f8790d4a authoriko <mail@iko.soy> dateSat 24 Aug 2024, 07:24 (2 years ago) parentc8ac053
1 file changed+16
nock/src/jets.rs+16
nock/src/jets.rs+16
@@ -55,6 +55,7 @@ pub fn generate_jets() -> Jets {
5555 (322006565952434408151902864454572452802, SNIP),
5656 (290837622185731774795798043954046795930, SNOC),
5757 (255402796382159268271460433298209603428, SORT),
58+ (10111398404342329752608067595798409804, SPIN),
5859 ])
5960}
6061
@@ -479,3 +480,18 @@ static SORT: Jet = |ctx, n| {
479480
480481 Noun::list_refs(v.iter().cloned())
481482};
483+
484+static SPIN: Jet = |ctx, n| {
485+ let (list, b) = n.as_cell().unwrap();
486+ let (mut acc, gate) = b.as_cell().unwrap();
487+
488+ let mut res = Vec::new();
489+
490+ for n in list.list_iter() {
491+ let (el, new_acc) = slam(ctx, gate.clone(), cell(n, acc)).as_cell().unwrap();
492+ acc = new_acc;
493+ res.push(el);
494+ }
495+
496+ cell(Noun::list_refs(res.iter().cloned()), acc)
497+};