Skip to content

Instantly share code, notes, and snippets.

@handicraftsman
Created November 3, 2018 10:24
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 handicraftsman/169e2b2d7016d12c308e64560729825e to your computer and use it in GitHub Desktop.
Save handicraftsman/169e2b2d7016d12c308e64560729825e to your computer and use it in GitHub Desktop.
For loop
// same code as in quill part, but in C++
{
int i = 0
contfunc = [&] () { i++; }
while (i < 10) {
std::cout << i << std::endl;
contfunc();
}
std::cout << "Done counting" << std::endl;
}
; for is a macro which must be imported
; Code below expands into something like code in cpp part, but in quill
(for (setv i:Int32 0)
while (< i 10)
step (set i (+ i 1))
do
(println (.toString i))
after
(println "Done counting"))
@handicraftsman
Copy link
Author

(do
  (defvar i:Int32)
  (set i 0)
  (defvar quill_continue_func:![]:Void)
  (set quill_continue_func
    (fn ![]:Void
      (set i (+ i 1))))
  (while (< i 10)
    (println (.toString i)))
  (println "Done counting"))

quill_continue_func will be called after each iteration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment