RECURSION

sometimes we want to double doubled numbers. sometimes we want to double doubled doubled numbers.

this language lets us do that.

TRANSLATED:



it's easy. [just] make the double function accept a number or ANOTHER double function.

const listTerm = new ListTerm([
	new StringTerm("double"),
	new MaybeTerm(new GapTerm()),
	new OrTerm([new TermTerm("number"), new TermTerm("double")]),
])

and we now need to make sure we EVALUATE the argument. we can't just use its bite ANYMORE. because it might be a function now.

const doubleTerm = new WithTerm(listTerm, {
	emit(text) {
		const [, , numberBite] = this.digest(text)
		const number = this.terms[2].emit(numberBite)
		return number * 2
	},
})

this is now a RECURSIVE term. so we can't CURRENTLY rely on the AUTOMATIC name GENERATION as the name will have INFINITE length and crash your computer. so let's [just] give it a PLACEHOLDER name until we solve that.

const doubleTerm = new WithTerm(listTerm, {
	//...
	name() {
		return "PLACEHOLDER"
	},
})

back to the dream