@@ -1,17 +1,39 @@
1use core::panic;
1use core::panic;
2+use murmur3::murmur3_32;
2use num_integer::Integer;
3use num_integer::Integer;
4 collections::BTreeMap,
6 collections::BTreeMap,
5 iter::{once, repeat_n, zip},
7 iter::{once, repeat_n, zip},
9use crate::{
11use crate::{
10− interpreter::{slam, InterpreterContext},
12+ interpreter::{slam_pulled_gate, InterpreterContext, TTanks, EMPTY_TANKS},
11− noun::{self, cell, Atom, Noun},
13+ noun::{self, cell, AsNoun, Atom, Edge, Hair, Nail, Noun},
16+fn traverse_iter_result<E: Clone, T: Clone, I: Iterator<Item = Result<T, E>>>(
18+) -> Result<Vec<T>, E> {
19+ let mut target: Vec<T> = Vec::new();
22+ target.push(x.clone()?)
14pub type Jets = BTreeMap<noun::Hash, Jet>;
28pub type Jets = BTreeMap<noun::Hash, Jet>;
29+pub type DoubleJets = BTreeMap<noun::Hash, DoubleJet>;
31+pub fn generate_double_jets() -> DoubleJets {
33+ (210326504639957723220404138306543145797, JUST),
34+ // (255213039400865122956425872354360738044, STIR),
16pub fn generate_jets() -> Jets {
38pub fn generate_jets() -> Jets {
17 BTreeMap::from([
39 BTreeMap::from([
@@ -51,43 +73,98 @@ pub fn generate_jets() -> Jets {
51 (144878877047435484372311285666595397017, SKIP),
73 (144878877047435484372311285666595397017, SKIP),
52 (22344664364706022641079203486385841813, SLAG),
74 (22344664364706022641079203486385841813, SLAG),
53 (288515703007942177334798811660651439897, SNAG),
75 (288515703007942177334798811660651439897, SNAG),
76+ (322006565952434408151902864454572452802, SNIP),
77+ (290837622185731774795798043954046795930, SNOC),
78+ // (255402796382159268271460433298209603428, SORT),
79+ (10111398404342329752608067595798409804, SPIN),
80+ (209194119090564757355985847956576215234, SPUN),
81+ (103985097318911737222583881947453560061, TURN),
82+ (216618478373489138062093083914898130454, WELD),
83+ (161636738411171172446435323238280743696, WELP),
84+ (90634096513747887582230817128332929026, ZING),
85+ (59352245691598674621226842217946522940, BEX),
86+ (102718716366123785010912772034318125155, END),
87+ (233905026649167301608240871123208487851, CAN),
88+ (88906713429699361214497715048276521868, CAT),
89+ (194217032002582779752566874231896746840, MET),
90+ (132848439781269254342687684309700447927, CUT),
91+ (184331043431916214773639930303095454137, FIL),
92+ (104452959965816676316166435675758878521, LSH),
93+ (84358434946425438379820219100952030132, RSH),
94+ (49642221456321333759873032692286222867, RAP),
95+ (92956425869648916777812729456192604084, REP),
96+ (302196507237993702819920888576650809366, REV),
97+ (111192034817574564051316537756194881830, RIP),
98+ (194882429025651072335997865399571359986, RUN),
99+ (52890757765966568893620799383929397067, RUT),
100+ (189837220965666741450798472864087835815, SEW),
101+ (122271149828189266412416527758198690539, SWP),
102+ (315388312266248574424227833154020891850, XEB),
103+ (26880808488368366377851132561579207892, CON),
104+ (311027486926441687148059942599447850754, DIS),
105+ (330927609077697663248483044495963838437, MIX),
106+ (39579736615539990724554083585557839000, NOT),
107+ (3482046397915506566435874021936376320, LAST),
108+ (124976064672625230427889101290245200507, TRIP),
109+ (4078279288073906183633157465551067635, MUK),
110+ (261900159748071234702685239353558471892, MUG),
111+ (198191257620924788695943358402651905954, AOR),
112+ (299422828284010240628877806738195667652, DOR),
113+ (166326796552601297695313176538120818632, GOR),
114+ (7942398240152905363972500667649380756, MOR),
115+ (315687984998079865981003916817293521765, LOOK),
57−pub type Jet = fn(ctx: &InterpreterContext, Rc<Noun>) -> Rc<Noun>;
119+pub type Jet = fn(ctx: &mut InterpreterContext, &Rc<Noun>) -> Result<Rc<Noun>, TTanks>;
120+pub type DoubleJet = fn(ctx: &mut InterpreterContext, &Rc<Noun>, &Rc<Noun>) -> Option<Rc<Noun>>;
59−static BINARY_ATOM: fn(Rc<Noun>, fn(&Atom, &Atom) -> Atom) -> Rc<Noun> =
122+static BINARY_ATOM: fn(&Rc<Noun>, fn(&Atom, &Atom) -> Atom) -> Result<Rc<Noun>, TTanks> =
60− |n: Rc<Noun>, f: fn(&Atom, &Atom) -> Atom| {
123+ |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> Atom| {
61− let Noun::Cell { p, q, .. } = (*n).clone() else {
124+ let (p, q) = n.as_cell().ok_or(TTanks::new())?;
64− Rc::new(Noun::Atom(f(p.as_atom().unwrap(), q.as_atom().unwrap())))
125+ Ok(Rc::new(Noun::Atom(f(
126+ p.as_atom().ok_or(TTanks::new())?,
127+ q.as_atom().ok_or(TTanks::new())?,
67−static BINARY_ATOM_LOOB: fn(&InterpreterContext, Rc<Noun>, fn(&Atom, &Atom) -> bool) -> Rc<Noun> =
131+static BINARY_ATOM_LOOB: fn(
132+ &InterpreterContext,
134+ fn(&Atom, &Atom) -> bool,
135+) -> Result<Rc<Noun>, TTanks> =
68− |ctx: &InterpreterContext, n: Rc<Noun>, f: fn(&Atom, &Atom) -> bool| {
136+ |ctx: &InterpreterContext, n: &Rc<Noun>, f: fn(&Atom, &Atom) -> bool| {
69− let Noun::Cell { p, q, .. } = (*n).clone() else {
137+ let (p, q) = n.as_cell().ok_or(TTanks::new())?;
72−
140+ p.as_atom().ok_or(TTanks::new())?,
73− if f(p.as_atom().unwrap(), q.as_atom().unwrap()) {
141+ q.as_atom().ok_or(TTanks::new())?,
74− ctx.nouns.sig.clone()
143+ Ok(ctx.nouns.sig.clone())
76− ctx.nouns.one.clone()
145+ Ok(ctx.nouns.one.clone())
80−static BINARY_ATOM_PAIR: fn(Rc<Noun>, fn(&Atom, &Atom) -> (Atom, Atom)) -> Rc<Noun> =
149+static BINARY_ATOM_PAIR: fn(
151+ fn(&Atom, &Atom) -> (Atom, Atom),
81− |n: Rc<Noun>, f: fn(&Atom, &Atom) -> (Atom, Atom)| {
152+) -> Result<Rc<Noun>, TTanks> = |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> (Atom, Atom)| {
82− let Noun::Cell { p, q, .. } = (*n).clone() else {
153+ let (p, q) = n.as_cell().ok_or(TTanks::new())?;
84− };
155+ let (a, b) = f(
85− let (a, b) = f(p.as_atom().unwrap(), q.as_atom().unwrap());
156+ p.as_atom().ok_or(TTanks::new())?,
157+ q.as_atom().ok_or(TTanks::new())?,
86− cell(Rc::new(Noun::Atom(a)), Rc::new(Noun::Atom(b)))
159+ Ok(cell(&Rc::new(Noun::Atom(a)), &Rc::new(Noun::Atom(b))))
89static ADD: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a + b);
162static ADD: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a + b);
90−static DEC: Jet = |_ctx, n| Rc::new(Noun::Atom(n.as_atom().unwrap() - 1u32));
163+static DEC: Jet = |_ctx, n| {
164+ Ok(Rc::new(Noun::Atom(
165+ n.as_atom().ok_or(TTanks::new())? - 1u32,
91static DVR: Jet = |_ctx, n| BINARY_ATOM_PAIR(n, |a, b| a.div_rem(&b));
168static DVR: Jet = |_ctx, n| BINARY_ATOM_PAIR(n, |a, b| a.div_rem(&b));
92static DIV: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a / b);
169static DIV: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a / b);
93static GTE: Jet = |ctx, n| BINARY_ATOM_LOOB(ctx, n, |a, b| a >= b);
170static GTE: Jet = |ctx, n| BINARY_ATOM_LOOB(ctx, n, |a, b| a >= b);
@@ -101,40 +178,42 @@ static MUL: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a * b);
101static SUB: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a - b);
178static SUB: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a - b);
103static CAP: Jet = |ctx, n| {
180static CAP: Jet = |ctx, n| {
104− let Noun::Atom(n) = (*n).clone() else {
181+ let n = n.as_atom().ok_or(TTanks::new())?;
107− CAP_ATOM(ctx, n)
182+ CAP_ATOM(ctx, n.clone())
109−static CAP_ATOM: fn(&InterpreterContext, Atom) -> Rc<Noun> = |ctx, n: Atom| {
185+static CAP_ATOM: fn(&InterpreterContext, Atom) -> Result<Rc<Noun>, TTanks> = |ctx, n: Atom| {
110 let mut n_iter = n.iter_u32_digits();
186 let mut n_iter = n.iter_u32_digits();
112 match n_iter.len() {
188 match n_iter.len() {
113− 0 => panic!(),
189+ 0 => Err(TTanks::new()),
114 1 => CAP_U32(ctx, n_iter.next().unwrap()),
190 1 => CAP_U32(ctx, n_iter.next().unwrap()),
115 _ => CAP_ATOM(ctx, n >> 1),
191 _ => CAP_ATOM(ctx, n >> 1),
118−static CAP_U32: fn(ctx: &InterpreterContext, u32) -> Rc<Noun> = |ctx, n| match n {
194+static CAP_U32: fn(ctx: &InterpreterContext, u32) -> Result<Rc<Noun>, TTanks> = |ctx, n| match n {
119− 0 | 1 => panic!(),
195+ 0 | 1 => Err(TTanks::new()),
120− 2 => ctx.nouns.two.clone(),
196+ 2 => Ok(ctx.nouns.two.clone()),
121− 3 => ctx.nouns.three.clone(),
197+ 3 => Ok(ctx.nouns.three.clone()),
122 n => CAP_U32(ctx, n >> 1),
198 n => CAP_U32(ctx, n >> 1),
125static MAS: Jet = |ctx, n| {
201static MAS: Jet = |ctx, n| {
126− let Noun::Atom(n) = (*n).clone() else {
202+ let n = n.as_atom().ok_or(TTanks::new())?;
129− Rc::new(Noun::Atom(MAS_ATOM(ctx, n)))
203+ Ok(Rc::new(Noun::Atom(
204+ MAS_ATOM(ctx, n.clone()).ok_or(TTanks::new())?,
131−static MAS_ATOM: fn(&InterpreterContext, Atom) -> Atom = |ctx, n| {
207+static MAS_ATOM: fn(&InterpreterContext, Atom) -> Option<Atom> = |ctx, n| {
132 let mut n_iter = n.iter_u32_digits();
208 let mut n_iter = n.iter_u32_digits();
134 match n_iter.len() {
210 match n_iter.len() {
135− 0 => panic!(),
211+ 0 => None,
212+ 1 => match n_iter.next().unwrap() {
136− 1 => Atom::new(vec![MAS_U32(n_iter.next().unwrap())]),
214+ x => Some(Atom::new(vec![MAS_U32(x)])),
137− _ => (&n & &ctx.big_uints.one) + (MAS_ATOM(ctx, &n >> 1) << 1),
216+ _ => Some((&n & &ctx.big_uints.one) + (MAS_ATOM(ctx, &n >> 1)? << 1)),
140static MAS_U32: fn(u32) -> u32 = |n| match n {
219static MAS_U32: fn(u32) -> u32 = |n| match n {
@@ -144,26 +223,24 @@ static MAS_U32: fn(u32) -> u32 = |n| match n {
146static PEG: Jet = |ctx, n| {
225static PEG: Jet = |ctx, n| {
147− let Noun::Cell { p: a, q: b, .. } = (*n).clone() else {
226+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
151− let a = a.as_atom().unwrap();
228+ let a = a.as_atom().ok_or(TTanks::new())?;
152− let b = b.as_atom().unwrap();
229+ let b = b.as_atom().ok_or(TTanks::new())?;
154 if *a == Atom::ZERO {
231 if *a == Atom::ZERO {
155− panic!()
232+ return Err(TTanks::new());
158− Rc::new(Noun::Atom(PEG_ATOM(ctx, a, b.clone())))
235+ Ok(Rc::new(Noun::Atom(PEG_ATOM(ctx, a, b.clone())?)))
160−static PEG_ATOM: fn(&InterpreterContext, &Atom, Atom) -> Atom = |ctx, a, b| {
237+static PEG_ATOM: fn(&InterpreterContext, &Atom, Atom) -> Result<Atom, TTanks> = |ctx, a, b| {
161 let mut b_iter = b.iter_u32_digits();
238 let mut b_iter = b.iter_u32_digits();
163 match b_iter.len() {
240 match b_iter.len() {
164− 0 => panic!(),
241+ 0 => Err(TTanks::new()),
165− 1 => PEG_U32(a, b_iter.next().unwrap()),
242+ 1 => Ok(PEG_U32(a, b_iter.next().unwrap())),
166− _ => (&b & &ctx.big_uints.one) + (PEG_ATOM(ctx, a, b >> 1) << 1),
243+ _ => Ok((&b & &ctx.big_uints.one) + (PEG_ATOM(ctx, a, b >> 1)? << 1)),
169static PEG_U32: fn(&Atom, u32) -> Atom = |a, b| match b {
246static PEG_U32: fn(&Atom, u32) -> Atom = |a, b| match b {
@@ -175,12 +252,12 @@ static PEG_U32: fn(&Atom, u32) -> Atom = |a, b| match b {
177static FAND: Jet = |ctx, n| {
254static FAND: Jet = |ctx, n| {
178− let (nedl, hstk) = n.as_cell().unwrap();
255+ let (nedl, hstk) = n.as_cell().ok_or(TTanks::new())?;
179 if nedl.is_sig() || hstk.is_sig() {
256 if nedl.is_sig() || hstk.is_sig() {
180− return ctx.nouns.sig.clone();
257+ return Ok(ctx.nouns.sig.clone());
183− let nedl: Vec<Rc<Noun>> = nedl.list_iter().collect();
260+ let nedl: Vec<&Rc<Noun>> = nedl.list_iter().collect();
185 let mut result: Vec<u32> = Vec::new();
262 let mut result: Vec<u32> = Vec::new();
@@ -201,16 +278,16 @@ static FAND: Jet = |ctx, n| {
201 inner_iter = iter.clone();
278 inner_iter = iter.clone();
204− Noun::list(result.iter().map(|a| Noun::from_u32(*a)))
281+ Ok(Noun::list(result.iter().map(|a| Noun::from_u32(*a))))
207static FIND: Jet = |ctx, n| {
284static FIND: Jet = |ctx, n| {
208− let (nedl, hstk) = n.as_cell().unwrap();
285+ let (nedl, hstk) = n.as_cell().ok_or(TTanks::new())?;
209 if nedl.is_sig() || hstk.is_sig() {
286 if nedl.is_sig() || hstk.is_sig() {
210− return ctx.nouns.sig.clone();
287+ return Ok(ctx.nouns.sig.clone());
213− let nedl: Vec<Rc<Noun>> = nedl.list_iter().collect();
290+ let nedl: Vec<&Rc<Noun>> = nedl.list_iter().collect();
215 let mut iter = zip(0.., hstk.list_iter());
292 let mut iter = zip(0.., hstk.list_iter());
@@ -223,28 +300,28 @@ static FIND: Jet = |ctx, n| {
223 .collect::<Vec<_>>()
300 .collect::<Vec<_>>()
226− return Rc::new(Noun::from_u32(i)).unit();
303+ return Ok(Rc::new(Noun::from_u32(i)).unit());
229 inner_iter = iter.clone();
306 inner_iter = iter.clone();
232− return ctx.nouns.sig.clone();
309+ return Ok(ctx.nouns.sig.clone());
235static FLOP: Jet = |ctx, n| {
312static FLOP: Jet = |ctx, n| {
236− n.list_iter()
313+ Ok(n.list_iter()
237− .fold(ctx.nouns.sig.clone(), |tail, head| cell(head, tail))
314+ .fold(ctx.nouns.sig.clone(), |tail, head| cell(&head, &tail)))
240static GULF: Jet = |_ctx, n| {
317static GULF: Jet = |_ctx, n| {
241− let (from, to) = n.as_cell().unwrap();
318+ let (from, to) = n.as_cell().ok_or(TTanks::new())?;
243− let mut from = (*from.as_atom().unwrap()).clone();
320+ let mut from = (*from.as_atom().ok_or(TTanks::new())?).clone();
244− let to = to.as_atom().unwrap().clone();
321+ let to = to.as_atom().ok_or(TTanks::new())?.clone();
246 if from > to {
323 if from > to {
247− panic!()
324+ return Err(TTanks::new());
250 let mut tmp = Vec::new();
327 let mut tmp = Vec::new();
@@ -254,182 +331,940 @@ static GULF: Jet = |_ctx, n| {
254 from += 1u32;
331 from += 1u32;
257− Noun::list(tmp.iter().rev().map(|a| Noun::Atom(a.clone())))
334+ Ok(Noun::list(tmp.iter().rev().map(|a| Noun::Atom(a.clone()))))
260static INTO: Jet = |_ctx, n| {
337static INTO: Jet = |_ctx, n| {
261− let (a, b) = n.as_cell().unwrap();
338+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
262− let (b, c) = b.as_cell().unwrap();
339+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
264− let mut b_iter = b.as_atom().unwrap().iter_u32_digits();
341+ let mut b_iter = b.as_atom().ok_or(TTanks::new())?.iter_u32_digits();
266 match b_iter.len() {
343 match b_iter.len() {
267− 0 => cell(c, a),
344+ 0 => Ok(cell(&c, &a)),
269 let l = a.list_iter();
346 let l = a.list_iter();
270 let b = b_iter.next().unwrap() as usize;
347 let b = b_iter.next().unwrap() as usize;
271− Noun::list_refs(
348+ Ok(Noun::list_refs(
272 l.clone()
349 l.clone()
274 .chain(once(c))
351 .chain(once(c))
275 .chain(l.skip(b))
352 .chain(l.skip(b))
276 .collect::<Vec<_>>()
353 .collect::<Vec<_>>()
278− .map(|x| x.clone()),
355+ .cloned()
281− _ => Noun::list_refs(
359+ _ => Ok(Noun::list_refs(
282 a.list_iter()
360 a.list_iter()
283 .chain(once(c))
361 .chain(once(c))
284 .collect::<Vec<_>>()
362 .collect::<Vec<_>>()
286− .map(|x| x.clone()),
364+ .cloned()
291static JOIN: Jet = |_ctx, n| {
370static JOIN: Jet = |_ctx, n| {
292− let (sep, list) = n.as_cell().unwrap();
371+ let (sep, list) = n.as_cell().ok_or(TTanks::new())?;
293− Noun::list_refs(
372+ Ok(Noun::list_refs(
294 list.list_iter()
373 list.list_iter()
295 .intersperse(sep)
374 .intersperse(sep)
296 .collect::<Vec<_>>()
375 .collect::<Vec<_>>()
298− .map(|x| x.clone()),
377+ .cloned()
382+static LENT: Jet = |_ctx, n| {
383+ Ok(Rc::new(Noun::from_u32(
302−static LENT: Jet = |_ctx, n| Rc::new(Noun::from_u32(n.list_iter().fold(0u32, |l, _| l + 1)));
384+ n.list_iter().fold(0u32, |l, _| l + 1),
304static LEVY: Jet = |ctx, n| {
388static LEVY: Jet = |ctx, n| {
305− let (a, b) = n.as_cell().unwrap();
389+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
306− if a.list_iter()
390+ if traverse_iter_result(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
307− .all(|n| slam(ctx, b.clone(), n) == ctx.nouns.y)
391+ .iter()
309− ctx.nouns.y.clone()
394+ Ok(ctx.nouns.y.clone())
311− ctx.nouns.n.clone()
396+ Ok(ctx.nouns.n.clone())
315static LIEN: Jet = |ctx, n| {
400static LIEN: Jet = |ctx, n| {
316− let (a, b) = n.as_cell().unwrap();
401+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
317− if a.list_iter()
402+ if traverse_iter_result(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
318− .any(|n| slam(ctx, b.clone(), n) == ctx.nouns.y)
403+ .iter()
320− ctx.nouns.y.clone()
406+ Ok(ctx.nouns.y.clone())
322− ctx.nouns.n.clone()
408+ Ok(ctx.nouns.n.clone())
326static MURN: Jet = |ctx, n| {
412static MURN: Jet = |ctx, n| {
327− let (a, b) = n.as_cell().unwrap();
413+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
329− Noun::list_refs(
415+ Ok(Noun::list_refs(
416+ traverse_iter_result(
330− a.list_iter()
417+ a.list_iter()
331− .filter_map(|n| slam(ctx, b.clone(), n).as_unit())
418+ .map(|n| Ok(slam_pulled_gate(ctx, b, n)?.as_unit().cloned())),
332− .collect::<Vec<_>>()
419+ )?
334− .map(|x| x.clone()),
421+ .filter_map(|x| x.clone()),
338static REAP: Jet = |_ctx, n| {
425static REAP: Jet = |_ctx, n| {
339− let (a, b) = n.as_cell().unwrap();
426+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
341− Noun::list_refs(repeat_n(b, a.as_u32().unwrap() as usize))
428+ Ok(Noun::list_refs(repeat_n(
430+ a.as_u32().unwrap() as usize,
344−static REAR: Jet = |_ctx, n| n.list_iter().last().unwrap();
434+static REAR: Jet = |_ctx, n| n.list_iter().last().ok_or(TTanks::new()).cloned();
346static REEL: Jet = |ctx, n| {
436static REEL: Jet = |ctx, n| {
347− let (list, gate) = n.as_cell().unwrap();
437+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
349 list.list_iter().collect::<Vec<_>>().iter().rfold(
439 list.list_iter().collect::<Vec<_>>().iter().rfold(
350− gate.clone().gate_sample().unwrap().as_cell().unwrap().1,
441+ .gate_sample()
442+ .ok_or(TTanks::new())?
444+ .ok_or(TTanks::new())?
351− |acc, next| slam(ctx, gate.clone(), cell(next.clone(), acc)),
449+ slam_pulled_gate(ctx, gate, &cell(&next, &acc))
355static ROLL: Jet = |ctx, n| {
454static ROLL: Jet = |ctx, n| {
356− let (list, gate) = n.as_cell().unwrap();
455+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
358 list.list_iter().fold(
457 list.list_iter().fold(
359− gate.clone().gate_sample().unwrap().as_cell().unwrap().1,
460+ .gate_sample()
461+ .ok_or(TTanks::new())?
463+ .ok_or(TTanks::new())?
360− |acc, next| slam(ctx, gate.clone(), cell(next.clone(), acc)),
468+ slam_pulled_gate(ctx, gate, &cell(&next, &acc))
364static SCAG: Jet = |_ctx, n| {
473static SCAG: Jet = |_ctx, n| {
365− let (a, b) = n.as_cell().unwrap();
474+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
367− Noun::list_refs(
476+ Ok(Noun::list_refs(
368 b.list_iter()
477 b.list_iter()
369 .take(a.as_u32().unwrap() as usize)
478 .take(a.as_u32().unwrap() as usize)
370 .collect::<Vec<_>>()
479 .collect::<Vec<_>>()
372− .map(|x| x.clone()),
481+ .cloned()
376static SKID: Jet = |ctx, n| {
486static SKID: Jet = |ctx, n| {
377− let (list, gate) = n.as_cell().unwrap();
487+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
379− let (ys, ns): (Vec<Rc<Noun>>, _) = list
489+ let slammed_n = traverse_iter_result(
380− .list_iter()
490+ list.list_iter()
381− .partition(|n| slam(ctx, gate.clone(), n.clone()).is_y());
491+ .map(|n| Ok((slam_pulled_gate(ctx, gate, n)?, n))),
493+ let (ys, ns): (Vec<_>, _) = slammed_n.iter().partition(|(l, _)| l.is_y());
384− Noun::list_refs(ys.iter().cloned()),
496+ &Noun::list_refs(ys.iter().map(|(_, x)| (*x).clone())),
385− Noun::list_refs(ns.iter().cloned()),
497+ &Noun::list_refs(ns.iter().map(|(_, x)| (*x).clone())),
389static SKIM: Jet = |ctx, n| {
501static SKIM: Jet = |ctx, n| {
390− let (list, gate) = n.as_cell().unwrap();
502+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
392− Noun::list_refs(
504+ Ok(Noun::list_refs(
505+ traverse_iter_result(
393− list.list_iter()
506+ list.list_iter()
394− .filter(|n| slam(ctx, gate.clone(), n.clone()).is_y())
507+ .map(|n| Ok((slam_pulled_gate(ctx, gate, n)?, n))),
395− .collect::<Vec<_>>()
508+ )?
397− .cloned(),
510+ .filter(|(l, _)| l.is_y())
511+ .map(|(_, x)| (*x).clone()),
401static SKIP: Jet = |ctx, n| {
515static SKIP: Jet = |ctx, n| {
402− let (list, gate) = n.as_cell().unwrap();
516+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
404− Noun::list_refs(
518+ Ok(Noun::list_refs(
519+ traverse_iter_result(
405− list.list_iter()
520+ list.list_iter()
406− .filter(|n| slam(ctx, gate.clone(), n.clone()).is_n())
521+ .map(|n| Ok((slam_pulled_gate(ctx, gate, n)?, n))),
407− .collect::<Vec<_>>()
522+ )?
409− .cloned(),
524+ .filter(|(l, _)| l.is_y())
525+ .map(|(_, x)| (*x).clone()),
413static SLAG: Jet = |ctx, n| {
529static SLAG: Jet = |ctx, n| {
414− let (a, list) = n.as_cell().unwrap();
530+ let (a, list) = n.as_cell().ok_or(TTanks::new())?;
416− let mut a_iter = a.as_atom().unwrap().iter_u32_digits();
532+ let mut a_iter = a.as_atom().ok_or(TTanks::new())?.iter_u32_digits();
418 match a_iter.len() {
534 match a_iter.len() {
419− 0 => list,
535+ 0 => Ok(list.clone()),
420− 1 => Noun::list_refs(
536+ 1 => Ok(Noun::list_refs(
421 list.list_iter()
537 list.list_iter()
422 .skip(a_iter.next().unwrap() as usize)
538 .skip(a_iter.next().unwrap() as usize)
423 .collect::<Vec<_>>()
539 .collect::<Vec<_>>()
425 .cloned(),
542 .cloned(),
427− _ => ctx.nouns.sig.clone(),
544+ _ => Ok(ctx.nouns.sig.clone()),
431static SNAG: Jet = |_ctx, n| {
548static SNAG: Jet = |_ctx, n| {
432− let (a, list) = n.as_cell().unwrap();
549+ let (a, list) = n.as_cell().ok_or(TTanks::new())?;
552+ .nth(a.as_u32().unwrap() as usize)
554+ .ok_or(TTanks::new())
557+static SNIP: Jet = |_ctx, n| {
560+ .collect::<Vec<_>>()
570+static SNOC: Jet = |_ctx, n| {
571+ let (list, b) = n.as_cell().ok_or(TTanks::new())?;
576+ .collect::<Vec<_>>()
583+// static SORT: Jet = |ctx, n| {
584+// let (list, lth) = n.as_cell().unwrap();
586+// let mut v: Vec<_> = list.list_iter().collect();
588+// v.sort_by(|a, b| {
589+// if slam(ctx, lth.clone(), cell(a.clone(), b.clone())) == ctx.nouns.some_y {
591+// } else if slam(ctx, lth.clone(), cell(b.clone(), a.clone())) == ctx.nouns.some_y {
598+// Some(Noun::list_refs(v.iter().cloned()))
601+static SPIN: Jet = |ctx, n| {
602+ let (list, b) = n.as_cell().ok_or(TTanks::new())?;
603+ let (acc, gate) = b.as_cell().ok_or(TTanks::new())?;
605+ let mut res = Vec::new();
606+ let mut acc = acc.clone();
608+ for n in list.list_iter() {
609+ let foo = slam_pulled_gate(ctx, gate, &cell(&n, &acc))?;
610+ let (el, new_acc) = foo.as_cell().ok_or(TTanks::new())?;
611+ acc = new_acc.clone();
612+ res.push(el.clone());
615+ Ok(cell(&Noun::list_refs(res.iter().cloned()), &acc))
618+static SPUN: Jet = |ctx, n| {
619+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
621+ let mut res = Vec::new();
624+ .ok_or(TTanks::new())?
626+ .ok_or(TTanks::new())?
630+ for n in list.list_iter() {
631+ let foo = slam_pulled_gate(ctx, gate, &cell(&n, &acc))?;
632+ let (el, new_acc) = foo.as_cell().ok_or(TTanks::new())?;
633+ acc = new_acc.clone();
634+ res.push(el.clone());
637+ Ok(cell(&Noun::list_refs(res.iter().cloned()), &acc))
640+static TURN: Jet = |ctx, n| {
641+ let (list, gate) = n.as_cell().ok_or(TTanks::new())?;
643+ traverse_iter_result(list.list_iter().map(|x| slam_pulled_gate(ctx, gate, x)))?
649+static WELD: Jet = |_ctx, n| {
650+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
654+ .chain(b.list_iter())
655+ .collect::<Vec<_>>()
662+static WELP: Jet = WELD;
664+static ZING: Jet = |_ctx, n| {
667+ .map(|l| l.list_iter())
669+ .collect::<Vec<_>>()
676+static BEX: Jet = |ctx, n| {
677+ Ok(Rc::new(Noun::Atom(
678+ &ctx.big_uints.one << n.as_u32().unwrap(),
682+static END: Jet = |ctx, n| {
683+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
684+ let bite = a.as_bite();
686+ let bits = bite.bits();
688+ let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
690+ Ok(Rc::new(Noun::Atom(
691+ mask & b.as_atom().ok_or(TTanks::new())?,
695+static CAN: Jet = |ctx, n| {
696+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
697+ let bloq = a.as_u32().unwrap();
698+ let bloq_ = 2u32.pow(bloq);
700+ let atom: Option<Atom> = b.list_iter().collect::<Vec<_>>().iter().rfold(
701+ Some(ctx.big_uints.zero.clone()),
703+ let (p, q) = next.as_cell()?;
704+ let step = p.as_u32().unwrap();
705+ let bits = bloq_ * step;
706+ let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
708+ Some((acc? << bits) | (mask & q.as_atom()?))
711+ Ok(Rc::new(Noun::Atom(atom.ok_or(TTanks::new())?)))
714+static CAT: Jet = |_ctx, n| {
715+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
716+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
718+ let bloq = bloq.as_u32().ok_or(TTanks::new())?;
719+ let b = b.as_atom().ok_or(TTanks::new())?;
720+ let c = c.as_atom().ok_or(TTanks::new())?;
722+ Ok(Rc::new(Noun::Atom(
723+ (c << (met(bloq, &b) * 2u32.pow(bloq))) | b,
727+static MET: Jet = |_ctx, n| {
728+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
729+ let b: Atom = b.as_atom().ok_or(TTanks::new())?.clone();
730+ let bloq = bloq.as_u32().unwrap();
732+ Ok(Rc::new(Noun::from_u32(met(bloq, &b))))
735+fn met(bloq: u32, a: &Atom) -> u32 {
736+ (a.bits() as u32).div_ceil(2u32.pow(bloq))
739+static CUT: Jet = |ctx, n| {
740+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
741+ let (b, d) = b.as_cell().ok_or(TTanks::new())?;
742+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
744+ let bits = 2u32.pow(a.as_u32().unwrap());
746+ let mask = (&ctx.big_uints.one << (bits * c.as_u32().unwrap())) - &ctx.big_uints.one;
748+ Ok(Rc::new(Noun::Atom(
749+ (d.as_atom().ok_or(TTanks::new())? >> (bits * b.as_u32().unwrap())) & mask,
753+static FIL: Jet = |ctx, n| {
754+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
755+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
757+ let bits = 2u32.pow(a.as_u32().unwrap());
759+ let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
761+ let src = c.as_atom().ok_or(TTanks::new())? & mask;
763+ let mut target = ctx.big_uints.zero.clone();
765+ for _ in 0..b.as_u32().unwrap() {
766+ target = (target << bits) | &src;
769+ Ok(Rc::new(Noun::Atom(target)))
772+static LSH: Jet = |_ctx, n| {
773+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
774+ let a = a.as_bite();
775+ let b = b.as_atom().ok_or(TTanks::new())?;
777+ Ok(Rc::new(Noun::Atom(b << a.bits())))
780+static RSH: Jet = |_ctx, n| {
781+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
782+ let a = a.as_bite();
783+ let b = b.as_atom().ok_or(TTanks::new())?;
785+ Ok(Rc::new(Noun::Atom(b >> a.bits())))
788+pub static RAP: Jet = |ctx, n| {
789+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
790+ let bloq = bloq.as_u32().unwrap();
791+ let bits = 2u32.pow(bloq);
793+ let mut target = ctx.big_uints.zero.clone();
795+ for el in b.list_iter().collect::<Vec<_>>().iter().rev() {
796+ let el = el.as_atom().ok_or(TTanks::new())?;
797+ if el != &ctx.big_uints.zero {
798+ target = (target << (bits * met(bloq, &el))) | el;
802+ Ok(Rc::new(Noun::Atom(target)))
805+static REP: Jet = |ctx, n| {
806+ let (bite, b) = n.as_cell().ok_or(TTanks::new())?;
807+ let bite = bite.as_bite();
809+ let bits = bite.bits();
810+ let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
812+ let mut target = ctx.big_uints.zero.clone();
814+ for el in b.list_iter().collect::<Vec<_>>().iter().rev() {
815+ target = (target << bits) | (el.as_atom().ok_or(TTanks::new())? & &mask);
434− list.list_iter().nth(a.as_u32().unwrap() as usize).unwrap()
818+ Ok(Rc::new(Noun::Atom(target)))
821+static REV: Jet = |ctx, n| {
822+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
823+ let (len, dat) = b.as_cell().ok_or(TTanks::new())?;
824+ let bloq = bloq.as_u32().unwrap();
825+ let len = len.as_u32().unwrap();
826+ let mut dat: Atom = dat.as_atom().ok_or(TTanks::new())?.clone();
828+ let bits = 2u32.pow(bloq);
829+ let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
831+ let mut target = ctx.big_uints.zero.clone();
834+ target = (target << bits) | (&mask & &dat);
838+ Ok(Rc::new(Noun::Atom(target)))
841+static RIP: Jet = |ctx, n| {
842+ let (bite, b) = n.as_cell().ok_or(TTanks::new())?;
843+ let bite = bite.as_bite();
844+ let mut b: Atom = b.as_atom().ok_or(TTanks::new())?.clone();
846+ let bits = bite.bits();
847+ let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
849+ let mut target = Vec::new();
851+ while b > ctx.big_uints.zero {
852+ target.push(Rc::new(Noun::Atom(&mask & &b)));
856+ Ok(Noun::list_refs(target.iter().cloned()))
859+static RUN: Jet = |ctx, n| {
860+ let (bite, b) = n.as_cell().ok_or(TTanks::new())?;
861+ let (b, gate) = b.as_cell().ok_or(TTanks::new())?;
863+ let bite = bite.as_bite();
864+ let mut b: Atom = b.as_atom().ok_or(TTanks::new())?.clone();
866+ let bits = bite.bits();
867+ let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
869+ let mut target = ctx.big_uints.zero.clone();
871+ while b > ctx.big_uints.zero {
872+ target = (target << bits)
873+ | ((*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?)
875+ .ok_or(TTanks::new())?
880+ Ok(Rc::new(Noun::Atom(target)))
883+static RUT: Jet = |ctx, n| {
884+ let (bite, b) = n.as_cell().ok_or(TTanks::new())?;
885+ let (b, gate) = b.as_cell().ok_or(TTanks::new())?;
887+ let bite = bite.as_bite();
888+ let mut b: Atom = b.as_atom().ok_or(TTanks::new())?.clone();
890+ let bits = bite.bits();
891+ let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
893+ let mut target = Vec::new();
895+ while b > ctx.big_uints.zero {
897+ (*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?)
899+ .ok_or(TTanks::new())?
905+ Ok(Noun::list(target.iter().cloned().map(Noun::Atom)))
908+static SEW: Jet = |ctx, n| {
909+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
910+ let (b, recipient) = b.as_cell().ok_or(TTanks::new())?;
911+ let (sew_start, c) = b.as_cell().ok_or(TTanks::new())?;
912+ let (number_of_blocks, donor) = c.as_cell().ok_or(TTanks::new())?;
913+ let recipient = recipient.as_atom().ok_or(TTanks::new())?;
914+ let donor = donor.as_atom().ok_or(TTanks::new())?;
916+ let bloq = a.as_u32().unwrap();
917+ let bits = 2u32.pow(bloq);
918+ let mask = ((&ctx.big_uints.one << (bits * number_of_blocks.as_u32().unwrap()))
919+ - &ctx.big_uints.one)
920+ << (sew_start.as_u32().unwrap() * bits);
922+ let apendix = recipient & &mask;
924+ let target = (recipient ^ apendix) | (donor & mask);
926+ Ok(Rc::new(Noun::Atom(target)))
929+static SWP: Jet = |ctx, n| {
930+ let (bloq, b) = n.as_cell().ok_or(TTanks::new())?;
931+ let bloq = bloq.as_u32().unwrap();
932+ let bits = 2u32.pow(bloq);
933+ let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
935+ let mut source = b.as_atom().ok_or(TTanks::new())?.clone();
936+ let mut target = ctx.big_uints.zero.clone();
938+ while source > ctx.big_uints.zero {
939+ target = (target << bits) | (&source & &mask);
940+ source = source >> bits;
943+ Ok(Rc::new(Noun::Atom(target)))
946+static XEB: Jet = |_ctx, n| {
947+ let mut a = n.as_atom().ok_or(TTanks::new())?.clone();
951+ while a > Atom::ZERO {
956+ Ok(Rc::new(Noun::from_u32(c)))
959+static CON: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a | b);
960+static DIS: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a & b);
961+static MIX: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a ^ b);
963+static NOT: Jet = |ctx, n| {
964+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
965+ let (b, c) = b.as_cell().ok_or(TTanks::new())?;
967+ let bloq = a.as_u32().unwrap();
968+ let bits = 2u32.pow(bloq);
969+ let mask = (&ctx.big_uints.one << (bits * b.as_u32().unwrap())) - &ctx.big_uints.one;
971+ let target = c.as_atom().ok_or(TTanks::new())? ^ &mask;
973+ Ok(Rc::new(Noun::Atom(target)))
976+static LAST: Jet = |_ctx, n| {
977+ let (a, b) = n.as_cell().ok_or(TTanks::new())?;
978+ let a = a.as_hair().ok_or(TTanks::new())?;
979+ let b = b.as_hair().ok_or(TTanks::new())?;
980+ Ok(Noun::from_hair(last(&a, &b)))
983+fn last<'a>(a: &'a Hair, b: &'a Hair) -> &'a Hair {
984+ if a.line == b.line {
985+ if a.column > b.column {
991+ if a.line > b.line {
999+static TRIP: Jet = |_ctx, n| {
1000+ let a = n.as_atom().ok_or(TTanks::new())?;
1002+ a.to_bytes_le().iter().map(|b| Noun::from_u32(*b as u32)),
1006+static MUK: Jet = |_ctx, n| {
1007+ let (seed, len) = n.as_cell().ok_or(TTanks::new())?;
1008+ let (len, key) = len.as_cell().ok_or(TTanks::new())?;
1009+ let seed = seed.as_u32().ok_or(TTanks::new())?;
1010+ let len = len.as_u32().ok_or(TTanks::new())?;
1011+ let key = key.as_atom().ok_or(TTanks::new())?;
1013+ Ok(Rc::new(Noun::from_u32(muk(seed, len, key))))
1016+static AOR: Jet = |ctx, n| {
1017+ let (a, b) = n.as_cell().ok_or(EMPTY_TANKS)?;
1020+ Ok(ctx.nouns.y.clone())
1022+ match (a.borrow(), b.borrow()) {
1023+ (Noun::Cell { .. }, Noun::Atom(_)) => Ok(ctx.nouns.n.clone()),
1024+ (Noun::Cell { p: a_p, q: a_q, .. }, Noun::Cell { p: b_p, q: b_q, .. }) => {
1026+ AOR(ctx, &cell(a_q, b_q))
1028+ AOR(ctx, &cell(a_p, b_p))
1031+ (Noun::Atom(_), Noun::Cell { .. }) => Ok(ctx.nouns.y.clone()),
1032+ (Noun::Atom(a), Noun::Atom(b)) => {
1033+ let a = a.to_bytes_le();
1034+ let b = b.to_bytes_le();
1038+ let c = a.get(i).unwrap_or(&0);
1039+ let d = b.get(i).unwrap_or(&0);
1045+ return Ok(ctx.nouns.y.clone());
1047+ return Ok(ctx.nouns.n.clone());
1056+static DOR: Jet = |ctx, n| {
1057+ let (a, b) = n.as_cell().ok_or(EMPTY_TANKS)?;
1060+ Ok(ctx.nouns.y.clone())
1062+ match (a.borrow(), b.borrow()) {
1063+ (Noun::Cell { .. }, Noun::Atom(_)) => Ok(ctx.nouns.n.clone()),
1064+ (Noun::Cell { p: a_p, q: a_q, .. }, Noun::Cell { p: b_p, q: b_q, .. }) => {
1066+ DOR(ctx, &cell(a_q, b_q))
1068+ DOR(ctx, &cell(a_p, b_p))
1071+ (Noun::Atom(_), Noun::Cell { .. }) => Ok(ctx.nouns.y.clone()),
1072+ (Noun::Atom(a), Noun::Atom(b)) => {
1074+ Ok(ctx.nouns.y.clone())
1076+ Ok(ctx.nouns.n.clone())
1083+static GOR: Jet = |ctx, n| {
1084+ let (a, b) = n.as_cell().ok_or(EMPTY_TANKS)?;
1092+ Ok(ctx.nouns.y.clone())
1094+ Ok(ctx.nouns.n.clone())
1099+static GOR_PAIR: fn(&mut InterpreterContext, &Rc<Noun>, &Rc<Noun>) -> Result<bool, TTanks> =
1105+ Ok(DOR(ctx, &(a.clone(), b.clone()).as_noun())? == ctx.nouns.y)
1111+static MOR: Jet = |ctx, n| {
1112+ let (a, b) = n.as_cell().ok_or(EMPTY_TANKS)?;
1113+ let c = Noun::from_u32(a.mug()).mug();
1114+ let d = Noun::from_u32(b.mug()).mug();
1120+ Ok(ctx.nouns.y.clone())
1122+ Ok(ctx.nouns.n.clone())
1127+static LOOK: Jet = |ctx, n| {
1128+ let (cog, dab) = n.as_cell().ok_or(EMPTY_TANKS)?;
1129+ LOOK_PAIR(ctx, Atom::new(vec![1]), cog, dab)
1132+static LOOK_PAIR: fn(
1133+ &mut InterpreterContext,
1137+) -> Result<Rc<Noun>, TTanks> = |ctx, axe, cog, dab| {
1139+ Ok(ctx.nouns.sig.clone())
1141+ let (node, b, c) = dab.tuple_3().ok_or(EMPTY_TANKS)?;
1144+ let (p, q) = node.as_cell().ok_or(EMPTY_TANKS)?;
1145+ if b.is_sig() && c.is_sig() {
1147+ Ok((ctx.nouns.sig.clone(), Noun::Atom(axe), q.clone()).as_noun())
1149+ Ok(ctx.nouns.sig.clone())
1151+ } else if b.is_sig() {
1153+ Ok((ctx.nouns.sig.clone(), PEG_U32(&axe, 2), q.clone()).as_noun())
1154+ } else if GOR_PAIR(ctx, cog, p)? {
1155+ Ok(ctx.nouns.sig.clone())
1157+ LOOK_PAIR(ctx, PEG_U32(&axe, 3), cog, r)
1159+ } else if c.is_sig() {
1161+ Ok((ctx.nouns.sig.clone(), PEG_U32(&axe, 2), q.clone()).as_noun())
1162+ } else if GOR_PAIR(ctx, cog, p)? {
1163+ LOOK_PAIR(ctx, PEG_U32(&axe, 3), cog, l)
1165+ Ok(ctx.nouns.sig.clone())
1169+ Ok((ctx.nouns.sig.clone(), PEG_U32(&axe, 2), q.clone()).as_noun())
1170+ } else if GOR_PAIR(ctx, cog, p)? {
1171+ LOOK_PAIR(ctx, PEG_U32(&axe, 6), cog, l)
1173+ LOOK_PAIR(ctx, PEG_U32(&axe, 7), cog, r)
1179+static JUST: DoubleJet = |ctx, n, m| {
1180+ let char = n.as_atom()?;
1181+ let nail = m.as_nail()?;
1182+ if *nail.rest == ctx.nouns.sig {
1183+ Some(fail(nail).as_noun())
1185+ let (i, _) = nail.rest.as_cell()?;
1186+ let i = i.as_atom()?;
1188+ Some(next(nail)?.as_noun())
1190+ Some(fail(nail).as_noun())
1195+// static STIR: DoubleJet = |ctx, n, m| {
1196+// let (rud, raq) = n.as_cell()?;
1197+// let (raq, fel) = raq.as_cell()?;
1198+// let tub = m.as_nail()?;
1200+// let mut lef = Vec::new();
1201+// let mut vex = slam(ctx, fel, tub)?.as;
1205+fn next<'a>(nail: Nail<'a>) -> Option<Edge<'a>> {
1206+ if **nail.rest == Noun::SIG {
1209+ let (i, t) = nail.rest.as_cell()?;
1210+ let zac = lust(i.as_atom()?.clone(), nail.hair);
1211+ // cell(zac, cell(Rc::new(Noun::SIG), cell(i, cell(zac, t))))
1214+ result: Some((i, Nail { hair: zac, rest: t })),
1219+fn lust(char: Atom, hair: Hair) -> Hair {
1220+ if char == Atom::from_slice(&vec![10]) {
1222+ line: hair.line + 1,
1228+ column: hair.column + 1,
1233+fn fail(nail: Nail) -> Edge {
1240+const MUG: Jet = |__ctx, n| Ok(Rc::new(Noun::from_u32(n.mug())));
1242+pub fn mum(syd: u32, fal: u32, key: &Atom) -> u32 {
1243+ let wyd = met(3, &key);
1249+ let haz = muk(syd, wyd, &key);
1250+ let ham = (haz >> 31) ^ (haz & !(1 << 31));
1261+fn muk(seed: u32, len: u32, key: &Atom) -> u32 {
1262+ let key: Vec<_> = key
1265+ .take(len as usize)
1269+ murmur3_32(&mut &*key, seed).unwrap()