From 1830133215449ebd32751aca7deb9b66663563bd Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Wed, 19 Apr 2023 16:25:30 +0100 Subject: Implements subex substitutions for the value register --- main/command.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'main') diff --git a/main/command.go b/main/command.go index 511bda8..ba6f9dc 100644 --- a/main/command.go +++ b/main/command.go @@ -109,7 +109,23 @@ type SubstituteCommand struct { subex subex.SubexState } func (cmd SubstituteCommand) exec(state *ProgramState) { - // TODO + valueStream := make(chan walk.WalkValue) + go func(in []walk.WalkValue, out chan<- walk.WalkValue) { + for _, value := range in { + out <- value + } + close(out) + }(state.value, valueStream) + atomStream := walk.Atomise(valueStream) + atomsOut, error := subex.RunTransducer(cmd.subex, atomStream) + if error { + panic("Error running subex") + } + valuesOut, err := walk.MemoryCompound(atomsOut) + if err != nil { + panic("Error compounding atoms") + } + state.value = valuesOut } type Command interface { -- cgit v1.2.3