Skip to content

Commit

Permalink
add simple evolog examples
Browse files Browse the repository at this point in the history
  • Loading branch information
madmike200590 committed Jan 11, 2024
1 parent 0bb76b1 commit 01c7038
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/greet-me.evl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
prompt_text("Hello user, what's your name? ").
write_prompt_res(R) : @streamWrite[STDOUT, PROMPT] = R :- prompt_text(PROMPT), &stdout(STDOUT).
usr_input_res(INP) : @streamReadLine[STDIN] = INP :- write_prompt_res(success(_)), &stdin(STDIN).
write_greeting_res(R) : @streamWrite[STDOUT, GREETING] = R :-
usr_input_res(success(line(NAME))),
&stdlib_string_concat["Hello, it is the utmost pleasure to finally greet you from an Evolog program, ", NAME](GREETING),
&stdout(STDOUT).
9 changes: 9 additions & 0 deletions examples/write_something.evl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
outfile("/home/michael/asp_snippets/evolog-actions/hello.out").

open_result(PATH, RES) : @fileOutputStream[PATH] = RES :- outfile(PATH).

write_result(PATH, RES) : @streamWrite[STREAM, "HelloEvologWorld!"] = RES :- open_result(PATH, success(stream(STREAM))), outfile(PATH).

can_close(PATH, FD) :- write_result(PATH, success(ok)), open_result(PATH, success(stream(FD))), outfile(PATH).

close_result(PATH, RES) : @outputStreamClose[STREAM] = RES :- write_result(PATH, success(ok)), open_result(PATH, success(stream(STREAM))), outfile(PATH).

0 comments on commit 01c7038

Please sign in to comment.