Skip to content

Instantly share code, notes, and snippets.

@mmerce
Created April 24, 2019 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmerce/83a2b9d639aaa0ca239fd7eb1273fee4 to your computer and use it in GitHub Desktop.
Save mmerce/83a2b9d639aaa0ca239fd7eb1273fee4 to your computer and use it in GitHub Desktop.
WhizzML executes WhizzML
;; Creating and executing dependent scripts.
;; script2 uses the output of an execution of script1 to multiply it by a number
;; As one script uses the execution of the previous script, they will be executed
;; in a sequence
;; creating the first script to add two numbers
(define script1 (create-script {"source_code" "(define sum (+ a b))"
"name" "Sum script"
"inputs" [{"type" "number" "name" "a"}
{"type" "number" "name" "b"}]
"outputs" [{"type" "number" "name" "sum"}]}))
;; creating a second script that uses the results of an existing execution to multiply them
;; by another number
(define script2
(create-script
{"source_code" (str "(define execution-info (fetch execution-id))"
"(let (sum (execution-info [\"execution\" \"result\"]))"
" (* sum c))")
"name" "Multiplication script"
"inputs" [{"type" "execution-id" "name" "execution-id"}
{"type" "number" "name" "c"}]}))
;; creating the execution of the first script
(define execution1 (create-execution {"script" script1
"inputs" [["a" 1] ["b" 2]]}))
;; creating the execution of the second script
(define final-execution
(create-and-wait-execution {"script" script2
"inputs" [["execution-id" execution1]
["c" 3]]}))
;; reading the result from the final execution
(define output ((fetch final-execution) ["execution" "result"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment