aboutsummaryrefslogtreecommitdiffstats
path: root/func.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2023-07-23 12:24:32 -0230
committerSam Anthony <sam@samanthony.xyz>2023-07-23 12:24:32 -0230
commit3951f8c09b3f49253cf0d354df708069223d0316 (patch)
tree6392fad888bfde768008c83b58dd1575f6c87f9f /func.go
parent4a585fba1ac08cd9f184627a4a8b781d0b52efcb (diff)
downloadpfc-3951f8c09b3f49253cf0d354df708069223d0316.zip
constant and function parsing skeleton
Diffstat (limited to 'func.go')
-rw-r--r--func.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/func.go b/func.go
new file mode 100644
index 0000000..914cb61
--- /dev/null
+++ b/func.go
@@ -0,0 +1,18 @@
+package main
+
+import "math"
+
+// parseFunction returns nil is s is not a valid function.
+func parseFunction(s string) func(Stack) {
+ switch s {
+ case "sin":
+ return sin
+ }
+ return nil
+}
+
+func sin(stack Stack) {
+ if len(stack) > 0 {
+ stack[len(stack)-1] = math.Sin(stack[len(stack)-1])
+ }
+}