<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main/command.go
diff options
context:
space:
mode:
Diffstat (limited to 'main/command.go')
-rw-r--r--main/command.go18
1 files changed, 17 insertions, 1 deletions
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 {