package main

import (
	"bufio"
	"fmt"
	"strings"
)

func opRun(val1 value) (value, bool) {
	if !isList(val1.val) {
		panic(fmt.Errorf("run: %s (%s)", errListExpected, val1.val))
	}
	return interpret(bufio.NewScanner(strings.NewReader(val1.val[1 : len(val1.val)-1])))
}

func opIf(val1, val2, val3 value) (value, bool) {
	b1 := toBool(val1.val)
	if b1 {
		return opRun(val2)
	}
	return opRun(val3)
}
