@@ -8,18 +8,20 @@ use std::{
10use crate::{
10use crate::{
11− interpreter::{slam_pulled_gate, InterpreterContext},
11+ interpreter::{slam_pulled_gate, InterpreterContext, Tanks},
12 noun::{self, cell, Atom, Edge, Hair, Nail, Noun},
12 noun::{self, cell, Atom, Edge, Hair, Nail, Noun},
15−fn traverse_iter_option<T: Clone, I: Iterator<Item = Option<T>>>(xs: I) -> Option<Vec<T>> {
15+fn traverse_iter_result<E: Clone, T: Clone, I: Iterator<Item = Result<T, E>>>(
17+) -> Result<Vec<T>, E> {
16 let mut target: Vec<T> = Vec::new();
18 let mut target: Vec<T> = Vec::new();
18 for x in xs {
20 for x in xs {
19 target.push(x.clone()?)
21 target.push(x.clone()?)
22− Some(target)
24+ Ok(target)
25pub type Jets = BTreeMap<noun::Hash, Jet>;
27pub type Jets = BTreeMap<noun::Hash, Jet>;
@@ -108,39 +110,51 @@ pub fn generate_jets() -> Jets {
111−pub type Jet = fn(ctx: &mut InterpreterContext, &Rc<Noun>) -> Option<Rc<Noun>>;
113+pub type Jet = fn(ctx: &mut InterpreterContext, &Rc<Noun>) -> Result<Rc<Noun>, Tanks>;
112pub type DoubleJet = fn(ctx: &mut InterpreterContext, &Rc<Noun>, &Rc<Noun>) -> Option<Rc<Noun>>;
114pub type DoubleJet = fn(ctx: &mut InterpreterContext, &Rc<Noun>, &Rc<Noun>) -> Option<Rc<Noun>>;
114−static BINARY_ATOM: fn(&Rc<Noun>, fn(&Atom, &Atom) -> Atom) -> Option<Rc<Noun>> =
116+static BINARY_ATOM: fn(&Rc<Noun>, fn(&Atom, &Atom) -> Atom) -> Result<Rc<Noun>, Tanks> =
115 |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> Atom| {
117 |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> Atom| {
116− let (p, q) = n.as_cell()?;
118+ let (p, q) = n.as_cell().ok_or(Tanks::new())?;
117− Some(Rc::new(Noun::Atom(f(p.as_atom()?, q.as_atom()?))))
119+ Ok(Rc::new(Noun::Atom(f(
120+ p.as_atom().ok_or(Tanks::new())?,
121+ q.as_atom().ok_or(Tanks::new())?,
120static BINARY_ATOM_LOOB: fn(
125static BINARY_ATOM_LOOB: fn(
121 &InterpreterContext,
126 &InterpreterContext,
122 &Rc<Noun>,
127 &Rc<Noun>,
123 fn(&Atom, &Atom) -> bool,
128 fn(&Atom, &Atom) -> bool,
129+) -> Result<Rc<Noun>, Tanks> =
124−) -> Option<Rc<Noun>> = |ctx: &InterpreterContext, n: &Rc<Noun>, f: fn(&Atom, &Atom) -> bool| {
130+ |ctx: &InterpreterContext, n: &Rc<Noun>, f: fn(&Atom, &Atom) -> bool| {
125− let (p, q) = n.as_cell()?;
131+ let (p, q) = n.as_cell().ok_or(Tanks::new())?;
127− if f(p.as_atom()?, q.as_atom()?) {
134+ p.as_atom().ok_or(Tanks::new())?,
135+ q.as_atom().ok_or(Tanks::new())?,
128− Some(ctx.nouns.sig.clone())
137+ Ok(ctx.nouns.sig.clone())
129− } else {
138+ } else {
130− Some(ctx.nouns.one.clone())
139+ Ok(ctx.nouns.one.clone())
134−static BINARY_ATOM_PAIR: fn(&Rc<Noun>, fn(&Atom, &Atom) -> (Atom, Atom)) -> Option<Rc<Noun>> =
143+static BINARY_ATOM_PAIR: fn(
145+ fn(&Atom, &Atom) -> (Atom, Atom),
135− |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> (Atom, Atom)| {
146+) -> Result<Rc<Noun>, Tanks> = |n: &Rc<Noun>, f: fn(&Atom, &Atom) -> (Atom, Atom)| {
136− let (p, q) = n.as_cell()?;
147+ let (p, q) = n.as_cell().ok_or(Tanks::new())?;
138− let (a, b) = f(p.as_atom()?, q.as_atom()?);
149+ let (a, b) = f(
150+ p.as_atom().ok_or(Tanks::new())?,
151+ q.as_atom().ok_or(Tanks::new())?,
139− Some(cell(&Rc::new(Noun::Atom(a)), &Rc::new(Noun::Atom(b))))
153+ Ok(cell(&Rc::new(Noun::Atom(a)), &Rc::new(Noun::Atom(b))))
142static ADD: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a + b);
156static ADD: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a + b);
143−static DEC: Jet = |_ctx, n| Some(Rc::new(Noun::Atom(n.as_atom()? - 1u32)));
157+static DEC: Jet = |_ctx, n| Ok(Rc::new(Noun::Atom(n.as_atom().ok_or(Tanks::new())? - 1u32)));
144static DVR: Jet = |_ctx, n| BINARY_ATOM_PAIR(n, |a, b| a.div_rem(&b));
158static DVR: Jet = |_ctx, n| BINARY_ATOM_PAIR(n, |a, b| a.div_rem(&b));
145static DIV: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a / b);
159static DIV: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a / b);
146static GTE: Jet = |ctx, n| BINARY_ATOM_LOOB(ctx, n, |a, b| a >= b);
160static GTE: Jet = |ctx, n| BINARY_ATOM_LOOB(ctx, n, |a, b| a >= b);
@@ -154,29 +168,31 @@ static MUL: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a * b);
154static SUB: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a - b);
168static SUB: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a - b);
156static CAP: Jet = |ctx, n| {
170static CAP: Jet = |ctx, n| {
157− let n = n.as_atom()?;
171+ let n = n.as_atom().ok_or(Tanks::new())?;
158 CAP_ATOM(ctx, n.clone())
172 CAP_ATOM(ctx, n.clone())
161−static CAP_ATOM: fn(&InterpreterContext, Atom) -> Option<Rc<Noun>> = |ctx, n: Atom| {
175+static CAP_ATOM: fn(&InterpreterContext, Atom) -> Result<Rc<Noun>, Tanks> = |ctx, n: Atom| {
162 let mut n_iter = n.iter_u32_digits();
176 let mut n_iter = n.iter_u32_digits();
164 match n_iter.len() {
178 match n_iter.len() {
165− 0 => None,
179+ 0 => Err(Tanks::new()),
166 1 => CAP_U32(ctx, n_iter.next().unwrap()),
180 1 => CAP_U32(ctx, n_iter.next().unwrap()),
167 _ => CAP_ATOM(ctx, n >> 1),
181 _ => CAP_ATOM(ctx, n >> 1),
170−static CAP_U32: fn(ctx: &InterpreterContext, u32) -> Option<Rc<Noun>> = |ctx, n| match n {
184+static CAP_U32: fn(ctx: &InterpreterContext, u32) -> Result<Rc<Noun>, Tanks> = |ctx, n| match n {
171− 0 | 1 => None,
185+ 0 | 1 => Err(Tanks::new()),
172− 2 => Some(ctx.nouns.two.clone()),
186+ 2 => Ok(ctx.nouns.two.clone()),
173− 3 => Some(ctx.nouns.three.clone()),
187+ 3 => Ok(ctx.nouns.three.clone()),
174 n => CAP_U32(ctx, n >> 1),
188 n => CAP_U32(ctx, n >> 1),
177static MAS: Jet = |ctx, n| {
191static MAS: Jet = |ctx, n| {
178− let n = n.as_atom()?;
192+ let n = n.as_atom().ok_or(Tanks::new())?;
179− Some(Rc::new(Noun::Atom(MAS_ATOM(ctx, n.clone())?)))
193+ Ok(Rc::new(Noun::Atom(
194+ MAS_ATOM(ctx, n.clone()).ok_or(Tanks::new())?,
181static MAS_ATOM: fn(&InterpreterContext, Atom) -> Option<Atom> = |ctx, n| {
197static MAS_ATOM: fn(&InterpreterContext, Atom) -> Option<Atom> = |ctx, n| {
182 let mut n_iter = n.iter_u32_digits();
198 let mut n_iter = n.iter_u32_digits();
@@ -197,24 +213,24 @@ static MAS_U32: fn(u32) -> u32 = |n| match n {
199static PEG: Jet = |ctx, n| {
215static PEG: Jet = |ctx, n| {
200− let (a, b) = n.as_cell()?;
216+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
202− let a = a.as_atom()?;
218+ let a = a.as_atom().ok_or(Tanks::new())?;
203− let b = b.as_atom()?;
219+ let b = b.as_atom().ok_or(Tanks::new())?;
205 if *a == Atom::ZERO {
221 if *a == Atom::ZERO {
206− return None;
222+ return Err(Tanks::new());
209− Some(Rc::new(Noun::Atom(PEG_ATOM(ctx, a, b.clone())?)))
225+ Ok(Rc::new(Noun::Atom(PEG_ATOM(ctx, a, b.clone())?)))
211−static PEG_ATOM: fn(&InterpreterContext, &Atom, Atom) -> Option<Atom> = |ctx, a, b| {
227+static PEG_ATOM: fn(&InterpreterContext, &Atom, Atom) -> Result<Atom, Tanks> = |ctx, a, b| {
212 let mut b_iter = b.iter_u32_digits();
228 let mut b_iter = b.iter_u32_digits();
214 match b_iter.len() {
230 match b_iter.len() {
215− 0 => None,
231+ 0 => Err(Tanks::new()),
216− 1 => Some(PEG_U32(a, b_iter.next().unwrap())),
232+ 1 => Ok(PEG_U32(a, b_iter.next().unwrap())),
217− _ => Some((&b & &ctx.big_uints.one) + (PEG_ATOM(ctx, a, b >> 1)? << 1)),
233+ _ => Ok((&b & &ctx.big_uints.one) + (PEG_ATOM(ctx, a, b >> 1)? << 1)),
220static PEG_U32: fn(&Atom, u32) -> Atom = |a, b| match b {
236static PEG_U32: fn(&Atom, u32) -> Atom = |a, b| match b {
@@ -226,9 +242,9 @@ static PEG_U32: fn(&Atom, u32) -> Atom = |a, b| match b {
228static FAND: Jet = |ctx, n| {
244static FAND: Jet = |ctx, n| {
229− let (nedl, hstk) = n.as_cell()?;
245+ let (nedl, hstk) = n.as_cell().ok_or(Tanks::new())?;
230 if nedl.is_sig() || hstk.is_sig() {
246 if nedl.is_sig() || hstk.is_sig() {
231− return Some(ctx.nouns.sig.clone());
247+ return Ok(ctx.nouns.sig.clone());
234 let nedl: Vec<&Rc<Noun>> = nedl.list_iter().collect();
250 let nedl: Vec<&Rc<Noun>> = nedl.list_iter().collect();
@@ -252,13 +268,13 @@ static FAND: Jet = |ctx, n| {
252 inner_iter = iter.clone();
268 inner_iter = iter.clone();
255− Some(Noun::list(result.iter().map(|a| Noun::from_u32(*a))))
271+ Ok(Noun::list(result.iter().map(|a| Noun::from_u32(*a))))
258static FIND: Jet = |ctx, n| {
274static FIND: Jet = |ctx, n| {
259− let (nedl, hstk) = n.as_cell()?;
275+ let (nedl, hstk) = n.as_cell().ok_or(Tanks::new())?;
260 if nedl.is_sig() || hstk.is_sig() {
276 if nedl.is_sig() || hstk.is_sig() {
261− return Some(ctx.nouns.sig.clone());
277+ return Ok(ctx.nouns.sig.clone());
264 let nedl: Vec<&Rc<Noun>> = nedl.list_iter().collect();
280 let nedl: Vec<&Rc<Noun>> = nedl.list_iter().collect();
@@ -274,30 +290,28 @@ static FIND: Jet = |ctx, n| {
274 .collect::<Vec<_>>()
290 .collect::<Vec<_>>()
277− return Some(Rc::new(Noun::from_u32(i)).unit());
293+ return Ok(Rc::new(Noun::from_u32(i)).unit());
280 inner_iter = iter.clone();
296 inner_iter = iter.clone();
283− return Some(ctx.nouns.sig.clone());
299+ return Ok(ctx.nouns.sig.clone());
286static FLOP: Jet = |ctx, n| {
302static FLOP: Jet = |ctx, n| {
288− n.list_iter()
303+ Ok(n.list_iter()
289− .fold(ctx.nouns.sig.clone(), |tail, head| cell(&head, &tail)),
304+ .fold(ctx.nouns.sig.clone(), |tail, head| cell(&head, &tail)))
293static GULF: Jet = |_ctx, n| {
307static GULF: Jet = |_ctx, n| {
294− let (from, to) = n.as_cell()?;
308+ let (from, to) = n.as_cell().ok_or(Tanks::new())?;
296− let mut from = (*from.as_atom()?).clone();
310+ let mut from = (*from.as_atom().ok_or(Tanks::new())?).clone();
297− let to = to.as_atom()?.clone();
311+ let to = to.as_atom().ok_or(Tanks::new())?.clone();
299 if from > to {
313 if from > to {
300− return None;
314+ return Err(Tanks::new());
303 let mut tmp = Vec::new();
317 let mut tmp = Vec::new();
@@ -307,105 +321,119 @@ static GULF: Jet = |_ctx, n| {
307 from += 1u32;
321 from += 1u32;
310− Some(Noun::list(tmp.iter().rev().map(|a| Noun::Atom(a.clone()))))
324+ Ok(Noun::list(tmp.iter().rev().map(|a| Noun::Atom(a.clone()))))
313static INTO: Jet = |_ctx, n| {
327static INTO: Jet = |_ctx, n| {
314− let (a, b) = n.as_cell()?;
328+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
315− let (b, c) = b.as_cell()?;
329+ let (b, c) = b.as_cell().ok_or(Tanks::new())?;
317− let mut b_iter = b.as_atom()?.iter_u32_digits();
331+ let mut b_iter = b.as_atom().ok_or(Tanks::new())?.iter_u32_digits();
319 match b_iter.len() {
333 match b_iter.len() {
320− 0 => Some(cell(&c, &a)),
334+ 0 => Ok(cell(&c, &a)),
322 let l = a.list_iter();
336 let l = a.list_iter();
323 let b = b_iter.next().unwrap() as usize;
337 let b = b_iter.next().unwrap() as usize;
324− Some(Noun::list_refs(
338+ Ok(Noun::list_refs(
325 l.clone()
339 l.clone()
327 .chain(once(c))
341 .chain(once(c))
328 .chain(l.skip(b))
342 .chain(l.skip(b))
329 .collect::<Vec<_>>()
343 .collect::<Vec<_>>()
331− .map(|x| *x),
345+ .cloned()
334− _ => Some(Noun::list_refs(
349+ _ => Ok(Noun::list_refs(
335 a.list_iter()
350 a.list_iter()
336 .chain(once(c))
351 .chain(once(c))
337 .collect::<Vec<_>>()
352 .collect::<Vec<_>>()
339 .cloned(),
355 .cloned(),
344static JOIN: Jet = |_ctx, n| {
360static JOIN: Jet = |_ctx, n| {
345− let (sep, list) = n.as_cell()?;
361+ let (sep, list) = n.as_cell().ok_or(Tanks::new())?;
346− Some(Noun::list_refs(
362+ Ok(Noun::list_refs(
347 list.list_iter()
363 list.list_iter()
348 .intersperse(sep)
364 .intersperse(sep)
349 .collect::<Vec<_>>()
365 .collect::<Vec<_>>()
351 .cloned(),
368 .cloned(),
355static LENT: Jet = |_ctx, n| {
372static LENT: Jet = |_ctx, n| {
356− Some(Rc::new(Noun::from_u32(
373+ Ok(Rc::new(Noun::from_u32(
357 n.list_iter().fold(0u32, |l, _| l + 1),
374 n.list_iter().fold(0u32, |l, _| l + 1),
361static LEVY: Jet = |ctx, n| {
378static LEVY: Jet = |ctx, n| {
362− let (a, b) = n.as_cell()?;
379+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
363− if traverse_iter_option(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
380+ if traverse_iter_result(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
365 .all(|x| x.is_y())
382 .all(|x| x.is_y())
367− Some(ctx.nouns.y.clone())
384+ Ok(ctx.nouns.y.clone())
369− Some(ctx.nouns.n.clone())
386+ Ok(ctx.nouns.n.clone())
373static LIEN: Jet = |ctx, n| {
390static LIEN: Jet = |ctx, n| {
374− let (a, b) = n.as_cell()?;
391+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
375− if traverse_iter_option(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
392+ if traverse_iter_result(a.list_iter().map(|n| slam_pulled_gate(ctx, b, n)))?
377 .any(|x| x.is_y())
394 .any(|x| x.is_y())
379− Some(ctx.nouns.y.clone())
396+ Ok(ctx.nouns.y.clone())
381− Some(ctx.nouns.n.clone())
398+ Ok(ctx.nouns.n.clone())
385static MURN: Jet = |ctx, n| {
402static MURN: Jet = |ctx, n| {
386− let (a, b) = n.as_cell()?;
403+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
388− Some(Noun::list_refs(
405+ Ok(Noun::list_refs(
406+ traverse_iter_result(
389− a.list_iter()
407+ a.list_iter()
390− .filter_map(|n| slam_pulled_gate(ctx, b, n)?.as_unit().cloned())
408+ .map(|n| Ok(slam_pulled_gate(ctx, b, n)?.as_unit().cloned())),
391− .collect::<Vec<_>>()
409+ )?
392− .iter(),
410+ .iter()
411+ .filter_map(|x| x.clone()),
396static REAP: Jet = |_ctx, n| {
415static REAP: Jet = |_ctx, n| {
397− let (a, b) = n.as_cell()?;
416+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
399− Some(Noun::list_refs(repeat_n(b, a.as_u32().unwrap() as usize)))
418+ Ok(Noun::list_refs(repeat_n(
420+ a.as_u32().unwrap() as usize,
402−static REAR: Jet = |_ctx, n| n.list_iter().last().cloned();
424+static REAR: Jet = |_ctx, n| n.list_iter().last().ok_or(Tanks::new()).cloned();
404static REEL: Jet = |ctx, n| {
426static REEL: Jet = |ctx, n| {
405− let (list, gate) = n.as_cell()?;
427+ let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
407 list.list_iter().collect::<Vec<_>>().iter().rfold(
429 list.list_iter().collect::<Vec<_>>().iter().rfold(
408− Some(gate.gate_sample()?.as_cell()?.1.clone()),
431+ .gate_sample()
432+ .ok_or(Tanks::new())?
434+ .ok_or(Tanks::new())?
409 |acc, next| {
437 |acc, next| {
410 let acc = acc?;
438 let acc = acc?;
411 slam_pulled_gate(ctx, gate, &cell(&next, &acc))
439 slam_pulled_gate(ctx, gate, &cell(&next, &acc))
@@ -414,10 +442,17 @@ static REEL: Jet = |ctx, n| {
416static ROLL: Jet = |ctx, n| {
444static ROLL: Jet = |ctx, n| {
417− let (list, gate) = n.as_cell()?;
445+ let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
419 list.list_iter().fold(
447 list.list_iter().fold(
420− Some(gate.clone().gate_sample()?.as_cell()?.1.clone()),
450+ .gate_sample()
451+ .ok_or(Tanks::new())?
453+ .ok_or(Tanks::new())?
421 |acc, next| {
456 |acc, next| {
422 let acc = acc?;
457 let acc = acc?;
423 slam_pulled_gate(ctx, gate, &cell(&next, &acc))
458 slam_pulled_gate(ctx, gate, &cell(&next, &acc))
@@ -426,105 +461,111 @@ static ROLL: Jet = |ctx, n| {
428static SCAG: Jet = |_ctx, n| {
463static SCAG: Jet = |_ctx, n| {
429− let (a, b) = n.as_cell()?;
464+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
431− Some(Noun::list_refs(
466+ Ok(Noun::list_refs(
432 b.list_iter()
467 b.list_iter()
433 .take(a.as_u32().unwrap() as usize)
468 .take(a.as_u32().unwrap() as usize)
434 .collect::<Vec<_>>()
469 .collect::<Vec<_>>()
436 .cloned(),
472 .cloned(),
440static SKID: Jet = |ctx, n| {
476static SKID: Jet = |ctx, n| {
441− let (list, gate) = n.as_cell()?;
477+ let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
443− let slammed_n = traverse_iter_option(
479+ let slammed_n = traverse_iter_result(
444 list.list_iter()
480 list.list_iter()
445− .map(|n| Some((slam_pulled_gate(ctx, gate, n)?, n))),
481+ .map(|n| Ok((slam_pulled_gate(ctx, gate, n)?, n))),
447 let (ys, ns): (Vec<_>, _) = slammed_n.iter().partition(|(l, _)| l.is_y());
483 let (ys, ns): (Vec<_>, _) = slammed_n.iter().partition(|(l, _)| l.is_y());
449− Some(cell(
485+ Ok(cell(
450− &Noun::list_refs(ys.iter().map(|(_, x)| *x)),
486+ &Noun::list_refs(ys.iter().map(|(_, x)| (*x).clone())),
451− &Noun::list_refs(ns.iter().map(|(_, x)| *x)),
487+ &Noun::list_refs(ns.iter().map(|(_, x)| (*x).clone())),
455static SKIM: Jet = |ctx, n| {
491static SKIM: Jet = |ctx, n| {
456− let (list, gate) = n.as_cell()?;
492+ let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
458− Some(Noun::list_refs(
494+ Ok(Noun::list_refs(
459− traverse_iter_option(
495+ traverse_iter_result(
460 list.list_iter()
496 list.list_iter()
461− .map(|n| Some((slam_pulled_gate(ctx, gate, n)?, n))),
497+ .map(|n| Ok((slam_pulled_gate(ctx, gate, n)?, n))),
464 .filter(|(l, _)| l.is_y())
500 .filter(|(l, _)| l.is_y())
465− .map(|(_, x)| *x),
501+ .map(|(_, x)| (*x).clone()),
469static SKIP: Jet = |ctx, n| {
505static SKIP: Jet = |ctx, n| {
470− let (list, gate) = n.as_cell()?;
506+ let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
472− Some(Noun::list_refs(
508+ Ok(Noun::list_refs(
473− traverse_iter_option(
509+ traverse_iter_result(
474 list.list_iter()
510 list.list_iter()
475− .map(|n| Some((slam_pulled_gate(ctx, gate, n)?, n))),
511+ .map(|n| Ok((slam_pulled_gate(ctx, gate, n)?, n))),
478 .filter(|(l, _)| l.is_y())
514 .filter(|(l, _)| l.is_y())
479− .map(|(_, x)| x)
515+ .map(|(_, x)| (*x).clone()),
484static SLAG: Jet = |ctx, n| {
519static SLAG: Jet = |ctx, n| {
485− let (a, list) = n.as_cell()?;
520+ let (a, list) = n.as_cell().ok_or(Tanks::new())?;
487− let mut a_iter = a.as_atom()?.iter_u32_digits();
522+ let mut a_iter = a.as_atom().ok_or(Tanks::new())?.iter_u32_digits();
489 match a_iter.len() {
524 match a_iter.len() {
490− 0 => Some(list.clone()),
525+ 0 => Ok(list.clone()),
491− 1 => Some(Noun::list_refs(
526+ 1 => Ok(Noun::list_refs(
492 list.list_iter()
527 list.list_iter()
493 .skip(a_iter.next().unwrap() as usize)
528 .skip(a_iter.next().unwrap() as usize)
494 .collect::<Vec<_>>()
529 .collect::<Vec<_>>()
496 .cloned(),
532 .cloned(),
498− _ => Some(ctx.nouns.sig.clone()),
534+ _ => Ok(ctx.nouns.sig.clone()),
502static SNAG: Jet = |_ctx, n| {
538static SNAG: Jet = |_ctx, n| {
503− let (a, list) = n.as_cell()?;
539+ let (a, list) = n.as_cell().ok_or(Tanks::new())?;
505− list.list_iter().nth(a.as_u32().unwrap() as usize).cloned()
542+ .nth(a.as_u32().unwrap() as usize)
544+ .ok_or(Tanks::new())
508static SNIP: Jet = |_ctx, n| {
547static SNIP: Jet = |_ctx, n| {
509− Some(Noun::list_refs(
548+ Ok(Noun::list_refs(
510 n.list_iter()
549 n.list_iter()
511 .collect::<Vec<_>>()
550 .collect::<Vec<_>>()
516 .cloned(),
556 .cloned(),
520static SNOC: Jet = |_ctx, n| {
560static SNOC: Jet = |_ctx, n| {
521− let (list, b) = n.as_cell()?;
561+ let (list, b) = n.as_cell().ok_or(Tanks::new())?;
523− Some(Noun::list_refs(
563+ Ok(Noun::list_refs(
524 list.list_iter()
564 list.list_iter()
525 .chain(once(b))
565 .chain(once(b))
526 .collect::<Vec<_>>()
566 .collect::<Vec<_>>()
528 .cloned(),
569 .cloned(),
@@ -548,53 +589,62 @@ static SNOC: Jet = |_ctx, n| {
550static SPIN: Jet = |ctx, n| {
591static SPIN: Jet = |ctx, n| {
551− let (list, b) = n.as_cell()?;
592+ let (list, b) = n.as_cell().ok_or(Tanks::new())?;
552− let (acc, gate) = b.as_cell()?;
593+ let (acc, gate) = b.as_cell().ok_or(Tanks::new())?;
554 let mut res = Vec::new();
595 let mut res = Vec::new();
555 let mut acc = acc.clone();
596 let mut acc = acc.clone();
557 for n in list.list_iter() {
598 for n in list.list_iter() {
558 let foo = slam_pulled_gate(ctx, gate, &cell(&n, &acc))?;
599 let foo = slam_pulled_gate(ctx, gate, &cell(&n, &acc))?;
559− let (el, new_acc) = foo.as_cell()?;
600+ let (el, new_acc) = foo.as_cell().ok_or(Tanks::new())?;
560 acc = new_acc.clone();
601 acc = new_acc.clone();
561 res.push(el.clone());
602 res.push(el.clone());
564− Some(cell(&Noun::list_refs(res.iter()), &acc))
605+ Ok(cell(&Noun::list_refs(res.iter().cloned()), &acc))
567static SPUN: Jet = |ctx, n| {
608static SPUN: Jet = |ctx, n| {
568− let (list, gate) = n.as_cell()?;
609+ let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
570 let mut res = Vec::new();
611 let mut res = Vec::new();
571− let mut acc = gate.gate_sample()?.as_cell()?.1.clone();
612+ let mut acc = gate
614+ .ok_or(Tanks::new())?
616+ .ok_or(Tanks::new())?
573 for n in list.list_iter() {
620 for n in list.list_iter() {
574 let foo = slam_pulled_gate(ctx, gate, &cell(&n, &acc))?;
621 let foo = slam_pulled_gate(ctx, gate, &cell(&n, &acc))?;
575− let (el, new_acc) = foo.as_cell()?;
622+ let (el, new_acc) = foo.as_cell().ok_or(Tanks::new())?;
576 acc = new_acc.clone();
623 acc = new_acc.clone();
577 res.push(el.clone());
624 res.push(el.clone());
580− Some(cell(&Noun::list_refs(res.iter()), &acc))
627+ Ok(cell(&Noun::list_refs(res.iter().cloned()), &acc))
583static TURN: Jet = |ctx, n| {
630static TURN: Jet = |ctx, n| {
584− let (list, gate) = n.as_cell()?;
631+ let (list, gate) = n.as_cell().ok_or(Tanks::new())?;
585− Some(Noun::list_refs(
632+ Ok(Noun::list_refs(
586− traverse_iter_option(list.list_iter().map(|x| slam_pulled_gate(ctx, gate, x)))?.iter(),
633+ traverse_iter_result(list.list_iter().map(|x| slam_pulled_gate(ctx, gate, x)))?
590static WELD: Jet = |_ctx, n| {
639static WELD: Jet = |_ctx, n| {
591− let (a, b) = n.as_cell()?;
640+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
593− Some(Noun::list_refs(
642+ Ok(Noun::list_refs(
594 a.list_iter()
643 a.list_iter()
595 .chain(b.list_iter())
644 .chain(b.list_iter())
596 .collect::<Vec<_>>()
645 .collect::<Vec<_>>()
598 .cloned(),
648 .cloned(),
@@ -602,35 +652,36 @@ static WELD: Jet = |_ctx, n| {
602static WELP: Jet = WELD;
652static WELP: Jet = WELD;
604static ZING: Jet = |_ctx, n| {
654static ZING: Jet = |_ctx, n| {
605− Some(Noun::list_refs(
655+ Ok(Noun::list_refs(
606 n.list_iter()
656 n.list_iter()
607 .map(|l| l.list_iter())
657 .map(|l| l.list_iter())
608 .flatten()
658 .flatten()
609 .collect::<Vec<_>>()
659 .collect::<Vec<_>>()
611 .cloned(),
662 .cloned(),
615static BEX: Jet = |ctx, n| {
666static BEX: Jet = |ctx, n| {
616− Some(Rc::new(Noun::Atom(
667+ Ok(Rc::new(Noun::Atom(
617 &ctx.big_uints.one << n.as_u32().unwrap(),
668 &ctx.big_uints.one << n.as_u32().unwrap(),
621static END: Jet = |ctx, n| {
672static END: Jet = |ctx, n| {
622− let (a, b) = n.as_cell()?;
673+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
623 let bite = a.as_bite();
674 let bite = a.as_bite();
625 let bits = bite.bits();
676 let bits = bite.bits();
627 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
678 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
629− Some(Rc::new(Noun::Atom(mask & b.as_atom()?)))
680+ Ok(Rc::new(Noun::Atom(mask & b.as_atom().ok_or(Tanks::new())?)))
632static CAN: Jet = |ctx, n| {
683static CAN: Jet = |ctx, n| {
633− let (a, b) = n.as_cell()?;
684+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
634 let bloq = a.as_u32().unwrap();
685 let bloq = a.as_u32().unwrap();
635 let bloq_ = 2u32.pow(bloq);
686 let bloq_ = 2u32.pow(bloq);
@@ -645,28 +696,28 @@ static CAN: Jet = |ctx, n| {
645 Some((acc? << bits) | (mask & q.as_atom()?))
696 Some((acc? << bits) | (mask & q.as_atom()?))
648− Some(Rc::new(Noun::Atom(atom?)))
699+ Ok(Rc::new(Noun::Atom(atom.ok_or(Tanks::new())?)))
651static CAT: Jet = |_ctx, n| {
702static CAT: Jet = |_ctx, n| {
652− let (bloq, b) = n.as_cell()?;
703+ let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
653− let (b, c) = b.as_cell()?;
704+ let (b, c) = b.as_cell().ok_or(Tanks::new())?;
655− let bloq = bloq.as_u32()?;
706+ let bloq = bloq.as_u32().ok_or(Tanks::new())?;
656− let b = b.as_atom()?;
707+ let b = b.as_atom().ok_or(Tanks::new())?;
657− let c = c.as_atom()?;
708+ let c = c.as_atom().ok_or(Tanks::new())?;
659− Some(Rc::new(Noun::Atom(
710+ Ok(Rc::new(Noun::Atom(
660 (c << (met(bloq, &b) * 2u32.pow(bloq))) | b,
711 (c << (met(bloq, &b) * 2u32.pow(bloq))) | b,
664static MET: Jet = |_ctx, n| {
715static MET: Jet = |_ctx, n| {
665− let (bloq, b) = n.as_cell()?;
716+ let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
666− let b: Atom = b.as_atom()?.clone();
717+ let b: Atom = b.as_atom().ok_or(Tanks::new())?.clone();
667 let bloq = bloq.as_u32().unwrap();
718 let bloq = bloq.as_u32().unwrap();
669− Some(Rc::new(Noun::from_u32(met(bloq, &b))))
720+ Ok(Rc::new(Noun::from_u32(met(bloq, &b))))
672fn met(bloq: u32, a: &Atom) -> u32 {
723fn met(bloq: u32, a: &Atom) -> u32 {
@@ -674,28 +725,28 @@ fn met(bloq: u32, a: &Atom) -> u32 {
676static CUT: Jet = |ctx, n| {
727static CUT: Jet = |ctx, n| {
677− let (a, b) = n.as_cell()?;
728+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
678− let (b, d) = b.as_cell()?;
729+ let (b, d) = b.as_cell().ok_or(Tanks::new())?;
679− let (b, c) = b.as_cell()?;
730+ let (b, c) = b.as_cell().ok_or(Tanks::new())?;
681 let bits = 2u32.pow(a.as_u32().unwrap());
732 let bits = 2u32.pow(a.as_u32().unwrap());
683 let mask = (&ctx.big_uints.one << (bits * c.as_u32().unwrap())) - &ctx.big_uints.one;
734 let mask = (&ctx.big_uints.one << (bits * c.as_u32().unwrap())) - &ctx.big_uints.one;
685− Some(Rc::new(Noun::Atom(
736+ Ok(Rc::new(Noun::Atom(
686− (d.as_atom()? >> (bits * b.as_u32().unwrap())) & mask,
737+ (d.as_atom().ok_or(Tanks::new())? >> (bits * b.as_u32().unwrap())) & mask,
690static FIL: Jet = |ctx, n| {
741static FIL: Jet = |ctx, n| {
691− let (a, b) = n.as_cell()?;
742+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
692− let (b, c) = b.as_cell()?;
743+ let (b, c) = b.as_cell().ok_or(Tanks::new())?;
694 let bits = 2u32.pow(a.as_u32().unwrap());
745 let bits = 2u32.pow(a.as_u32().unwrap());
696 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
747 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
698− let src = c.as_atom()? & mask;
749+ let src = c.as_atom().ok_or(Tanks::new())? & mask;
700 let mut target = ctx.big_uints.zero.clone();
751 let mut target = ctx.big_uints.zero.clone();
@@ -703,44 +754,44 @@ static FIL: Jet = |ctx, n| {
703 target = (target << bits) | &src;
754 target = (target << bits) | &src;
706− Some(Rc::new(Noun::Atom(target)))
757+ Ok(Rc::new(Noun::Atom(target)))
709static LSH: Jet = |_ctx, n| {
760static LSH: Jet = |_ctx, n| {
710− let (a, b) = n.as_cell()?;
761+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
711 let a = a.as_bite();
762 let a = a.as_bite();
712− let b = b.as_atom()?;
763+ let b = b.as_atom().ok_or(Tanks::new())?;
714− Some(Rc::new(Noun::Atom(b << a.bits())))
765+ Ok(Rc::new(Noun::Atom(b << a.bits())))
717static RSH: Jet = |_ctx, n| {
768static RSH: Jet = |_ctx, n| {
718− let (a, b) = n.as_cell()?;
769+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
719 let a = a.as_bite();
770 let a = a.as_bite();
720− let b = b.as_atom()?;
771+ let b = b.as_atom().ok_or(Tanks::new())?;
722− Some(Rc::new(Noun::Atom(b >> a.bits())))
773+ Ok(Rc::new(Noun::Atom(b >> a.bits())))
725static RAP: Jet = |ctx, n| {
776static RAP: Jet = |ctx, n| {
726− let (bloq, b) = n.as_cell()?;
777+ let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
727 let bloq = bloq.as_u32().unwrap();
778 let bloq = bloq.as_u32().unwrap();
728 let bits = 2u32.pow(bloq);
779 let bits = 2u32.pow(bloq);
730 let mut target = ctx.big_uints.zero.clone();
781 let mut target = ctx.big_uints.zero.clone();
732 for el in b.list_iter().collect::<Vec<_>>().iter().rev() {
783 for el in b.list_iter().collect::<Vec<_>>().iter().rev() {
733− let el = el.as_atom()?;
784+ let el = el.as_atom().ok_or(Tanks::new())?;
734 if el != &ctx.big_uints.zero {
785 if el != &ctx.big_uints.zero {
735 target = (target << (bits * met(bloq, &el))) | el;
786 target = (target << (bits * met(bloq, &el))) | el;
739− Some(Rc::new(Noun::Atom(target)))
790+ Ok(Rc::new(Noun::Atom(target)))
742static REP: Jet = |ctx, n| {
793static REP: Jet = |ctx, n| {
743− let (bite, b) = n.as_cell()?;
794+ let (bite, b) = n.as_cell().ok_or(Tanks::new())?;
744 let bite = bite.as_bite();
795 let bite = bite.as_bite();
746 let bits = bite.bits();
797 let bits = bite.bits();
@@ -749,18 +800,18 @@ static REP: Jet = |ctx, n| {
749 let mut target = ctx.big_uints.zero.clone();
800 let mut target = ctx.big_uints.zero.clone();
751 for el in b.list_iter().collect::<Vec<_>>().iter().rev() {
802 for el in b.list_iter().collect::<Vec<_>>().iter().rev() {
752− target = (target << bits) | (el.as_atom()? & &mask);
803+ target = (target << bits) | (el.as_atom().ok_or(Tanks::new())? & &mask);
755− Some(Rc::new(Noun::Atom(target)))
806+ Ok(Rc::new(Noun::Atom(target)))
758static REV: Jet = |ctx, n| {
809static REV: Jet = |ctx, n| {
759− let (bloq, b) = n.as_cell()?;
810+ let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
760− let (len, dat) = b.as_cell()?;
811+ let (len, dat) = b.as_cell().ok_or(Tanks::new())?;
761 let bloq = bloq.as_u32().unwrap();
812 let bloq = bloq.as_u32().unwrap();
762 let len = len.as_u32().unwrap();
813 let len = len.as_u32().unwrap();
763− let mut dat: Atom = dat.as_atom()?.clone();
814+ let mut dat: Atom = dat.as_atom().ok_or(Tanks::new())?.clone();
765 let bits = 2u32.pow(bloq);
816 let bits = 2u32.pow(bloq);
766 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
817 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -772,13 +823,13 @@ static REV: Jet = |ctx, n| {
772 dat = dat >> bits;
823 dat = dat >> bits;
775− Some(Rc::new(Noun::Atom(target)))
826+ Ok(Rc::new(Noun::Atom(target)))
778static RIP: Jet = |ctx, n| {
829static RIP: Jet = |ctx, n| {
779− let (bite, b) = n.as_cell()?;
830+ let (bite, b) = n.as_cell().ok_or(Tanks::new())?;
780 let bite = bite.as_bite();
831 let bite = bite.as_bite();
781− let mut b: Atom = b.as_atom()?.clone();
832+ let mut b: Atom = b.as_atom().ok_or(Tanks::new())?.clone();
783 let bits = bite.bits();
834 let bits = bite.bits();
784 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
835 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -790,15 +841,15 @@ static RIP: Jet = |ctx, n| {
790 b = b >> bits;
841 b = b >> bits;
793− Some(Noun::list_refs(target.iter()))
844+ Ok(Noun::list_refs(target.iter().cloned()))
796static RUN: Jet = |ctx, n| {
847static RUN: Jet = |ctx, n| {
797− let (bite, b) = n.as_cell()?;
848+ let (bite, b) = n.as_cell().ok_or(Tanks::new())?;
798− let (b, gate) = b.as_cell()?;
849+ let (b, gate) = b.as_cell().ok_or(Tanks::new())?;
800 let bite = bite.as_bite();
851 let bite = bite.as_bite();
801− let mut b: Atom = b.as_atom()?.clone();
852+ let mut b: Atom = b.as_atom().ok_or(Tanks::new())?.clone();
803 let bits = bite.bits();
854 let bits = bite.bits();
804 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
855 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -807,20 +858,22 @@ static RUN: Jet = |ctx, n| {
808 while b > ctx.big_uints.zero {
859 while b > ctx.big_uints.zero {
809 target = (target << bits)
860 target = (target << bits)
810− | ((*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?).as_atom()?
861+ | ((*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?)
863+ .ok_or(Tanks::new())?
811 & &mask);
864 & &mask);
812 b = b >> bits;
865 b = b >> bits;
815− Some(Rc::new(Noun::Atom(target)))
868+ Ok(Rc::new(Noun::Atom(target)))
818static RUT: Jet = |ctx, n| {
871static RUT: Jet = |ctx, n| {
819− let (bite, b) = n.as_cell()?;
872+ let (bite, b) = n.as_cell().ok_or(Tanks::new())?;
820− let (b, gate) = b.as_cell()?;
873+ let (b, gate) = b.as_cell().ok_or(Tanks::new())?;
822 let bite = bite.as_bite();
875 let bite = bite.as_bite();
823− let mut b: Atom = b.as_atom()?.clone();
876+ let mut b: Atom = b.as_atom().ok_or(Tanks::new())?.clone();
825 let bits = bite.bits();
878 let bits = bite.bits();
826 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
879 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
@@ -829,21 +882,24 @@ static RUT: Jet = |ctx, n| {
830 while b > ctx.big_uints.zero {
883 while b > ctx.big_uints.zero {
831 target.push(
884 target.push(
832− (*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?).as_atom()? & &mask,
885+ (*slam_pulled_gate(ctx, gate, &Rc::new(Noun::Atom(&mask & &b)))?)
887+ .ok_or(Tanks::new())?
834 b = b >> bits;
890 b = b >> bits;
837− Some(Noun::list(target.iter().cloned().map(Noun::Atom)))
893+ Ok(Noun::list(target.iter().cloned().map(Noun::Atom)))
840static SEW: Jet = |ctx, n| {
896static SEW: Jet = |ctx, n| {
841− let (a, b) = n.as_cell()?;
897+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
842− let (b, recipient) = b.as_cell()?;
898+ let (b, recipient) = b.as_cell().ok_or(Tanks::new())?;
843− let (sew_start, c) = b.as_cell()?;
899+ let (sew_start, c) = b.as_cell().ok_or(Tanks::new())?;
844− let (number_of_blocks, donor) = c.as_cell()?;
900+ let (number_of_blocks, donor) = c.as_cell().ok_or(Tanks::new())?;
845− let recipient = recipient.as_atom()?;
901+ let recipient = recipient.as_atom().ok_or(Tanks::new())?;
846− let donor = donor.as_atom()?;
902+ let donor = donor.as_atom().ok_or(Tanks::new())?;
848 let bloq = a.as_u32().unwrap();
904 let bloq = a.as_u32().unwrap();
849 let bits = 2u32.pow(bloq);
905 let bits = 2u32.pow(bloq);
@@ -855,16 +911,16 @@ static SEW: Jet = |ctx, n| {
856 let target = (recipient ^ apendix) | (donor & mask);
912 let target = (recipient ^ apendix) | (donor & mask);
858− Some(Rc::new(Noun::Atom(target)))
914+ Ok(Rc::new(Noun::Atom(target)))
861static SWP: Jet = |ctx, n| {
917static SWP: Jet = |ctx, n| {
862− let (bloq, b) = n.as_cell()?;
918+ let (bloq, b) = n.as_cell().ok_or(Tanks::new())?;
863 let bloq = bloq.as_u32().unwrap();
919 let bloq = bloq.as_u32().unwrap();
864 let bits = 2u32.pow(bloq);
920 let bits = 2u32.pow(bloq);
865 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
921 let mask = (&ctx.big_uints.one << bits) - &ctx.big_uints.one;
867− let mut source = b.as_atom()?.clone();
923+ let mut source = b.as_atom().ok_or(Tanks::new())?.clone();
868 let mut target = ctx.big_uints.zero.clone();
924 let mut target = ctx.big_uints.zero.clone();
870 while source > ctx.big_uints.zero {
926 while source > ctx.big_uints.zero {
@@ -872,11 +928,11 @@ static SWP: Jet = |ctx, n| {
872 source = source >> bits;
928 source = source >> bits;
875− Some(Rc::new(Noun::Atom(target)))
931+ Ok(Rc::new(Noun::Atom(target)))
878static XEB: Jet = |_ctx, n| {
934static XEB: Jet = |_ctx, n| {
879− let mut a = n.as_atom()?.clone();
935+ let mut a = n.as_atom().ok_or(Tanks::new())?.clone();
881 let mut c = 0;
937 let mut c = 0;
@@ -885,7 +941,7 @@ static XEB: Jet = |_ctx, n| {
888− Some(Rc::new(Noun::from_u32(c)))
944+ Ok(Rc::new(Noun::from_u32(c)))
891static CON: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a | b);
947static CON: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a | b);
@@ -893,23 +949,23 @@ static DIS: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a & b);
893static MIX: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a ^ b);
949static MIX: Jet = |_ctx, n| BINARY_ATOM(n, |a, b| a ^ b);
895static NOT: Jet = |ctx, n| {
951static NOT: Jet = |ctx, n| {
896− let (a, b) = n.as_cell()?;
952+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
897− let (b, c) = b.as_cell()?;
953+ let (b, c) = b.as_cell().ok_or(Tanks::new())?;
899 let bloq = a.as_u32().unwrap();
955 let bloq = a.as_u32().unwrap();
900 let bits = 2u32.pow(bloq);
956 let bits = 2u32.pow(bloq);
901 let mask = (&ctx.big_uints.one << (bits * b.as_u32().unwrap())) - &ctx.big_uints.one;
957 let mask = (&ctx.big_uints.one << (bits * b.as_u32().unwrap())) - &ctx.big_uints.one;
903− let target = c.as_atom()? ^ &mask;
959+ let target = c.as_atom().ok_or(Tanks::new())? ^ &mask;
905− Some(Rc::new(Noun::Atom(target)))
961+ Ok(Rc::new(Noun::Atom(target)))
908static LAST: Jet = |_ctx, n| {
964static LAST: Jet = |_ctx, n| {
909− let (a, b) = n.as_cell()?;
965+ let (a, b) = n.as_cell().ok_or(Tanks::new())?;
910− let a = a.as_hair()?;
966+ let a = a.as_hair().ok_or(Tanks::new())?;
911− let b = b.as_hair()?;
967+ let b = b.as_hair().ok_or(Tanks::new())?;
912− Some(Noun::from_hair(last(&a, &b)))
968+ Ok(Noun::from_hair(last(&a, &b)))
915fn last<'a>(a: &'a Hair, b: &'a Hair) -> &'a Hair {
971fn last<'a>(a: &'a Hair, b: &'a Hair) -> &'a Hair {
@@ -929,20 +985,20 @@ fn last<'a>(a: &'a Hair, b: &'a Hair) -> &'a Hair {
931static TRIP: Jet = |_ctx, n| {
987static TRIP: Jet = |_ctx, n| {
932− let a = n.as_atom()?;
988+ let a = n.as_atom().ok_or(Tanks::new())?;
933− Some(Noun::list(
989+ Ok(Noun::list(
934 a.to_bytes_le().iter().map(|b| Noun::from_u32(*b as u32)),
990 a.to_bytes_le().iter().map(|b| Noun::from_u32(*b as u32)),
938static MUK: Jet = |_ctx, n| {
994static MUK: Jet = |_ctx, n| {
939− let (seed, len) = n.as_cell()?;
995+ let (seed, len) = n.as_cell().ok_or(Tanks::new())?;
940− let (len, key) = len.as_cell()?;
996+ let (len, key) = len.as_cell().ok_or(Tanks::new())?;
941− let seed = seed.as_u32()?;
997+ let seed = seed.as_u32().ok_or(Tanks::new())?;
942− let len = len.as_u32()?;
998+ let len = len.as_u32().ok_or(Tanks::new())?;
943− let key = key.as_atom()?;
999+ let key = key.as_atom().ok_or(Tanks::new())?;
945− Some(Rc::new(Noun::from_u32(muk(seed, len, key))))
1001+ Ok(Rc::new(Noun::from_u32(muk(seed, len, key))))
948static JUST: DoubleJet = |ctx, n, m| {
1004static JUST: DoubleJet = |ctx, n, m| {
@@ -1006,7 +1062,7 @@ fn fail(nail: Nail) -> Edge {
1009−const MUG: Jet = |__ctx, n| Some(Rc::new(Noun::from_u32(n.mug())));
1065+const MUG: Jet = |__ctx, n| Ok(Rc::new(Noun::from_u32(n.mug())));
1011pub fn mum(syd: u32, fal: u32, key: &Atom) -> u32 {
1067pub fn mum(syd: u32, fal: u32, key: &Atom) -> u32 {
1012 let wyd = met(3, &key);
1068 let wyd = met(3, &key);