Created
April 24, 2019 21:43
-
-
Save mmerce/83a2b9d639aaa0ca239fd7eb1273fee4 to your computer and use it in GitHub Desktop.
WhizzML executes WhizzML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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