The Machines · Runtime stack

seedseq

A reckoner seed: list and pair structure — machines/seeds/seedseq.shoddy

the seedseq machine's icon

Summary

seedseq bridges list and pair structure into the reckoner, Shoddy’s stack calculator. A seed is a short file that registers one machine’s words with the reckoner. RANGE LENGTH REVERSE CONCAT FIRST REST SORTL work on a LIST cell. PAIR HEAD TAIL work on a PAIR cell — "rate" 0.05 PAIR puts a record on the stack, the calculator’s working pile of values. Most of these words are one line over a builtin the language already has (Range, Length, Reverse, Concat, Sort); a builtin is a word the language itself supplies. This seed’s only job is to fence off the cases those builtins Error on.

Why It's Useful

SORTL is the one word here that is not a thin wrapper. A Cell is a record, and the Sort builtin wants raw Numbers or Strings, so it cannot see through one. SORTL unwraps a homogeneous list — one where every element is the same kind — sorts the raw values, and wraps the answer back up. It refuses any other list by name: a mixed list, or one whose kind has no order. So a bad list never reaches Sort to be Errored on.

User's Guide

Let st0 = RckSeedSeq(RckNew())
RckEval(st0, "1 5 RANGE")                       ' x: { 1 2 3 4 5 }
RckEval(st0, "{ 3 1 2 } SORTL")                 ' x: { 1 2 3 }
RckEval(st0, Chr(34) & "rate" & Chr(34) & " 0.05 PAIR")  ' x: ( "rate" 0.05 )

HEAD and TAIL take a pair back apart. That lets a program carry a labelled value without a dictionary:

RckEval(st0, "HEAD")   ' x: "rate"
RckEval(st0, "TAIL")   ' x: 0.05

Word Reference

WordDescription
RANGE ( a b -- list )The whole numbers from a up to b, one cell per value; empty when b is below a.
LENGTH ( list -- n )How many elements a list holds.
REVERSE ( list -- list )The list back to front.
CONCAT ( xs ys -- list )Two lists joined end to end.
FIRST ( list -- x )The first element of a list; refuses an empty list.
REST ( list -- list )The list without its first element; refuses an empty list.
SORTL ( list -- list )A list of numbers or a list of strings, sorted ascending; refuses a mixed list or one whose kind has no order.
PAIR ( a b -- pair )Two cells joined as one record.
HEAD ( pair -- a )The first cell of a pair.
TAIL ( pair -- b )The second cell of a pair.

Who Uses It

UserHow
halifaxRANGE, SORTL, REVERSE and CONCAT: the list words the combinators are typed alongside.
sparkySparky folds it too, so a model calling eval reaches the same words halifax puts at a prompt.

A mill — a complete Shoddy program — claims this seed by folding RckSeedSeq over its reckoner state. That is all halifax does.

The Machines It Uses

MachineWhy
cuttleThe Cell type, including CutPair and CutList, every word here reads and answers.
reckonerRckReg, RckSeeding and the argument readers every registered word is built from.
seqRange, Length, Reverse, Concat, Sort, Fst and Snd back every word directly.