@@ -108,20 +108,20 @@ pub fn generate_jets() -> Jets {
111−pub type Jet = fn(ctx: &InterpreterContext, Rc<Noun>) -> Option<Rc<Noun>>;
111+pub type Jet = fn(ctx: &InterpreterContext, &Rc<Noun>) -> Option<Rc<Noun>>;
112−pub type DoubleJet = fn(ctx: &InterpreterContext, Rc<Noun>, Rc<Noun>) -> Option<Rc<Noun>>;
112+pub type DoubleJet = fn(ctx: &InterpreterContext, &Rc<Noun>, &Rc<Noun>) -> Option<Rc<Noun>>;
114−static BINARY_ATOM: fn(Rc<Noun>, fn(&Atom, &Atom) -> Atom) -> Option<Rc<Noun>> =
114+static BINARY_ATOM: fn(&Rc<Noun>, fn(&Atom, &Atom) -> Atom) -> Option<Rc<Noun>> =
115− |n: Rc<Noun>, f: fn(&Atom, &Atom) -> Atom| {
115+ |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> Atom| {
116 let (p, q) = n.as_cell()?;
116 let (p, q) = n.as_cell()?;
117 Some(Rc::new(Noun::Atom(f(p.as_atom()?, q.as_atom()?))))
117 Some(Rc::new(Noun::Atom(f(p.as_atom()?, q.as_atom()?))))
120static BINARY_ATOM_LOOB: fn(
120static BINARY_ATOM_LOOB: fn(
121 &InterpreterContext,
121 &InterpreterContext,
122− Rc<Noun>,
122+ &Rc<Noun>,
123 fn(&Atom, &Atom) -> bool,
123 fn(&Atom, &Atom) -> bool,
124−) -> Option<Rc<Noun>> = |ctx: &InterpreterContext, n: Rc<Noun>, f: fn(&Atom, &Atom) -> bool| {
124+) -> Option<Rc<Noun>> = |ctx: &InterpreterContext, n: &Rc<Noun>, f: fn(&Atom, &Atom) -> bool| {
125 let (p, q) = n.as_cell()?;
125 let (p, q) = n.as_cell()?;
127 if f(p.as_atom()?, q.as_atom()?) {
127 if f(p.as_atom()?, q.as_atom()?) {
@@ -131,12 +131,12 @@ static BINARY_ATOM_LOOB: fn(
134−static BINARY_ATOM_PAIR: fn(Rc<Noun>, fn(&Atom, &Atom) -> (Atom, Atom)) -> Option<Rc<Noun>> =
134+static BINARY_ATOM_PAIR: fn(&Rc<Noun>, fn(&Atom, &Atom) -> (Atom, Atom)) -> Option<Rc<Noun>> =
135− |n: Rc<Noun>, f: fn(&Atom, &Atom) -> (Atom, Atom)| {
135+ |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> (Atom, Atom)| {
136 let (p, q) = n.as_cell()?;
136 let (p, q) = n.as_cell()?;
138 let (a, b) = f(p.as_atom()?, q.as_atom()?);
138 let (a, b) = f(p.as_atom()?, q.as_atom()?);
139− Some(cell(&Noun::Atom(a), &Noun::Atom(b)))
139+ Some(cell(&Rc::new(Noun::Atom(a)), &Rc::new(Noun::Atom(b))))
142static ADD: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a + b);
142static ADD: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a + b);
@@ -231,7 +231,7 @@ static FAND: Jet = |ctx, n| {
231 return Some(ctx.nouns.sig.clone());
231 return Some(ctx.nouns.sig.clone());
234− let nedl: Vec<Rc<Noun>> = nedl.list_iter().collect();
234+ let nedl: Vec<&Rc<Noun>> = nedl.list_iter().collect();
236 let mut result: Vec<u32> = Vec::new();
236 let mut result: Vec<u32> = Vec::new();
@@ -261,7 +261,7 @@ static FIND: Jet = |ctx, n| {
261 return Some(ctx.nouns.sig.clone());
261 return Some(ctx.nouns.sig.clone());
264− let nedl: Vec<Rc<Noun>> = nedl.list_iter().collect();
264+ let nedl: Vec<&Rc<Noun>> = nedl.list_iter().collect();
266 let mut iter = zip(0.., hstk.list_iter());
266 let mut iter = zip(0.., hstk.list_iter());
@@ -328,7 +328,7 @@ static INTO: Jet = |_ctx, n| {
328 .chain(l.skip(b))
328 .chain(l.skip(b))
329 .collect::<Vec<_>>()
329 .collect::<Vec<_>>()
331− .map(|x| x.clone()),
331+ .map(|x| *x),
334 _ => Some(Noun::list_refs(
334 _ => Some(Noun::list_refs(
@@ -360,7 +360,7 @@ static LENT: Jet = |_ctx, n| {
361static LEVY: Jet = |ctx, n| {
361static LEVY: Jet = |ctx, n| {
362 let (a, b) = n.as_cell()?;
362 let (a, b) = n.as_cell()?;
363− if traverse_iter_option(a.list_iter().map(|n| slam(ctx, b.clone(), n)))?
363+ if traverse_iter_option(a.list_iter().map(|n| slam(ctx, b, n)))?
365 .all(|x| x.is_y())
365 .all(|x| x.is_y())
@@ -372,7 +372,7 @@ static LEVY: Jet = |ctx, n| {
373static LIEN: Jet = |ctx, n| {
373static LIEN: Jet = |ctx, n| {
374 let (a, b) = n.as_cell()?;
374 let (a, b) = n.as_cell()?;
375− if traverse_iter_option(a.list_iter().map(|n| slam(ctx, b.clone(), n)))?
375+ if traverse_iter_option(a.list_iter().map(|n| slam(ctx, b, n)))?
377 .any(|x| x.is_y())
377 .any(|x| x.is_y())
@@ -387,10 +387,9 @@ static MURN: Jet = |ctx, n| {
388 Some(Noun::list_refs(
388 Some(Noun::list_refs(
389 a.list_iter()
389 a.list_iter()
390− .filter_map(|n| slam(ctx, b.clone(), n)?.as_unit())
390+ .filter_map(|n| slam(ctx, b, n)?.as_unit().cloned())
391 .collect::<Vec<_>>()
391 .collect::<Vec<_>>()
392− .iter()
392+ .iter(),
393− .map(|x| x.clone()),
@@ -400,16 +399,16 @@ static REAP: Jet = |_ctx, n| {
400 Some(Noun::list_refs(repeat_n(b, a.as_u32().unwrap() as usize)))
399 Some(Noun::list_refs(repeat_n(b, a.as_u32().unwrap() as usize)))
403−static REAR: Jet = |_ctx, n| n.list_iter().last();
402+static REAR: Jet = |_ctx, n| n.list_iter().last().cloned();
405static REEL: Jet = |ctx, n| {
404static REEL: Jet = |ctx, n| {
406 let (list, gate) = n.as_cell()?;
405 let (list, gate) = n.as_cell()?;
408 list.list_iter().collect::<Vec<_>>().iter().rfold(
407 list.list_iter().collect::<Vec<_>>().iter().rfold(
409− Some(gate.clone().gate_sample()?.as_cell()?.1),
408+ Some(gate.gate_sample()?.as_cell()?.1.clone()),
410 |acc, next| {
409 |acc, next| {
411 let acc = acc?;
410 let acc = acc?;
412− slam(ctx, gate.clone(), cell(&next, &acc))
411+ slam(ctx, gate, &cell(&next, &acc))
@@ -418,10 +417,10 @@ static ROLL: Jet = |ctx, n| {
418 let (list, gate) = n.as_cell()?;
417 let (list, gate) = n.as_cell()?;
420 list.list_iter().fold(
419 list.list_iter().fold(
421− Some(gate.clone().gate_sample()?.as_cell()?.1),
420+ Some(gate.clone().gate_sample()?.as_cell()?.1.clone()),
422 |acc, next| {
421 |acc, next| {
423 let acc = acc?;
422 let acc = acc?;
424− slam(ctx, gate.clone(), cell(&next, &acc))
423+ slam(ctx, gate, &cell(&next, &acc))
@@ -441,10 +440,7 @@ static SCAG: Jet = |_ctx, n| {
441static SKID: Jet = |ctx, n| {
440static SKID: Jet = |ctx, n| {
442 let (list, gate) = n.as_cell()?;
441 let (list, gate) = n.as_cell()?;
444− let slammed_n = traverse_iter_option(
443+ let slammed_n = traverse_iter_option(list.list_iter().map(|n| Some((slam(ctx, gate, n)?, n))))?;
446− .map(|n| Some((slam(ctx, gate.clone(), n.clone())?, n))),
448 let (ys, ns): (Vec<_>, _) = slammed_n.iter().partition(|(l, _)| l.is_y());
444 let (ys, ns): (Vec<_>, _) = slammed_n.iter().partition(|(l, _)| l.is_y());
450 Some(cell(
446 Some(cell(
@@ -457,14 +453,10 @@ static SKIM: Jet = |ctx, n| {
457 let (list, gate) = n.as_cell()?;
453 let (list, gate) = n.as_cell()?;
459 Some(Noun::list_refs(
455 Some(Noun::list_refs(
460− traverse_iter_option(
456+ traverse_iter_option(list.list_iter().map(|n| Some((slam(ctx, gate, n)?, n))))?
462− .map(|n| Some((slam(ctx, gate.clone(), n.clone())?, n))),
465− .filter(|(l, _)| l.is_y())
458+ .filter(|(l, _)| l.is_y())
466− .map(|(_, x)| x)
459+ .map(|(_, x)| *x),
@@ -472,14 +464,11 @@ static SKIP: Jet = |ctx, n| {
472 let (list, gate) = n.as_cell()?;
464 let (list, gate) = n.as_cell()?;
474 Some(Noun::list_refs(
466 Some(Noun::list_refs(
475− traverse_iter_option(
467+ traverse_iter_option(list.list_iter().map(|n| Some((slam(ctx, gate, n)?, n))))?
477− .map(|n| Some((slam(ctx, gate.clone(), n.clone())?, n))),
480− .filter(|(l, _)| l.is_y())
469+ .filter(|(l, _)| l.is_y())
481− .map(|(_, x)| x)
470+ .map(|(_, x)| x)
482− .cloned(),
471+ .cloned(),
@@ -489,7 +478,7 @@ static SLAG: Jet = |ctx, n| {
489 let mut a_iter = a.as_atom()?.iter_u32_digits();
478 let mut a_iter = a.as_atom()?.iter_u32_digits();
491 match a_iter.len() {
480 match a_iter.len() {
492− 0 => Some(list),
481+ 0 => Some(list.clone()),
493 1 => Some(Noun::list_refs(
482 1 => Some(Noun::list_refs(
494 list.list_iter()
483 list.list_iter()
495 .skip(a_iter.next().unwrap() as usize)
484 .skip(a_iter.next().unwrap() as usize)
@@ -504,7 +493,7 @@ static SLAG: Jet = |ctx, n| {
504static SNAG: Jet = |_ctx, n| {
493static SNAG: Jet = |_ctx, n| {
505 let (a, list) = n.as_cell()?;
494 let (a, list) = n.as_cell()?;
507− list.list_iter().nth(a.as_u32().unwrap() as usize)
496+ list.list_iter().nth(a.as_u32().unwrap() as usize).cloned()
510static SNIP: Jet = |_ctx, n| {
499static SNIP: Jet = |_ctx, n| {
@@ -551,40 +540,41 @@ static SNOC: Jet = |_ctx, n| {
552static SPIN: Jet = |ctx, n| {
541static SPIN: Jet = |ctx, n| {
553 let (list, b) = n.as_cell()?;
542 let (list, b) = n.as_cell()?;
554− let (mut acc, gate) = b.as_cell()?;
543+ let (acc, gate) = b.as_cell()?;
556 let mut res = Vec::new();
545 let mut res = Vec::new();
546+ let mut acc = acc.clone();
558 for n in list.list_iter() {
548 for n in list.list_iter() {
559− let (el, new_acc) = slam(ctx, gate.clone(), cell(&n, &acc))?.as_cell()?;
549+ let foo = slam(ctx, gate, &cell(&n, &acc))?;
550+ let (el, new_acc) = foo.as_cell()?;
560− acc = new_acc;
551+ acc = new_acc.clone();
561− res.push(el);
552+ res.push(el.clone());
564− Some(cell(&Noun::list_refs(res.iter().cloned()), &acc))
555+ Some(cell(&Noun::list_refs(res.iter()), &acc))
567static SPUN: Jet = |ctx, n| {
558static SPUN: Jet = |ctx, n| {
568 let (list, gate) = n.as_cell()?;
559 let (list, gate) = n.as_cell()?;
570 let mut res = Vec::new();
561 let mut res = Vec::new();
571− let mut acc = gate.clone().gate_sample()?.as_cell()?.1;
562+ let mut acc = gate.gate_sample()?.as_cell()?.1.clone();
573 for n in list.list_iter() {
564 for n in list.list_iter() {
574− let (el, new_acc) = slam(ctx, gate.clone(), cell(&n, &acc))?.as_cell()?;
565+ let foo = slam(ctx, gate, &cell(&n, &acc))?;
566+ let (el, new_acc) = foo.as_cell()?;
575− acc = new_acc;
567+ acc = new_acc.clone();
576− res.push(el);
568+ res.push(el.clone());
579− Some(cell(&Noun::list_refs(res.iter().cloned()), &acc))
571+ Some(cell(&Noun::list_refs(res.iter()), &acc))
582static TURN: Jet = |ctx, n| {
574static TURN: Jet = |ctx, n| {
583 let (list, gate) = n.as_cell()?;
575 let (list, gate) = n.as_cell()?;
584 Some(Noun::list_refs(
576 Some(Noun::list_refs(
585− traverse_iter_option(list.list_iter().map(|x| slam(ctx, gate.clone(), x)))?
577+ traverse_iter_option(list.list_iter().map(|x| slam(ctx, gate, x)))?.iter(),
@@ -791,7 +781,7 @@ static RIP: Jet = |ctx, n| {
791 b = b >> bits;
781 b = b >> bits;
794− Some(Noun::list_refs(target.iter().cloned()))
784+ Some(Noun::list_refs(target.iter()))
797static RUN: Jet = |ctx, n| {
787static RUN: Jet = |ctx, n| {
@@ -808,7 +798,7 @@ static RUN: Jet = |ctx, n| {
809 while b > ctx.big_uints.zero {
799 while b > ctx.big_uints.zero {
810 target = (target << bits)
800 target = (target << bits)
811− | ((*slam(ctx, gate.clone(), Rc::new(Noun::Atom(&mask & &b)))?).as_atom()? & &mask);
801+ | ((*slam(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?).as_atom()? & &mask);
812 b = b >> bits;
802 b = b >> bits;
@@ -828,8 +818,7 @@ static RUT: Jet = |ctx, n| {
828 let mut target = Vec::new();
818 let mut target = Vec::new();
830 while b > ctx.big_uints.zero {
820 while b > ctx.big_uints.zero {
832− .push((*slam(ctx, gate.clone(), Rc::new(Noun::Atom(&mask & &b)))?).as_atom()? & &mask);
821+ target.push((*slam(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?).as_atom()? & &mask);
833 b = b >> bits;
822 b = b >> bits;
@@ -956,7 +945,7 @@ static MUK: Jet = |_ctx, n| {
956static JUST: DoubleJet = |ctx, n, m| {
945static JUST: DoubleJet = |ctx, n, m| {
957 let char = n.as_atom()?;
946 let char = n.as_atom()?;
958 let nail = m.as_nail()?;
947 let nail = m.as_nail()?;
959− if nail.rest == ctx.nouns.sig {
948+ if *nail.rest == ctx.nouns.sig {
960 Some(fail(nail).as_noun())
949 Some(fail(nail).as_noun())
962 let (i, _) = nail.rest.as_cell()?;
951 let (i, _) = nail.rest.as_cell()?;
@@ -979,8 +968,8 @@ static JUST: DoubleJet = |ctx, n, m| {
979// if vex.
968// if vex.
982−fn next(nail: Nail) -> Option<Edge> {
971+fn next<'a>(nail: Nail<'a>) -> Option<Edge<'a>> {
983− if *nail.rest == Noun::SIG {
972+ if **nail.rest == Noun::SIG {
984 Some(fail(nail))
973 Some(fail(nail))
986 let (i, t) = nail.rest.as_cell()?;
975 let (i, t) = nail.rest.as_cell()?;