Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hy is a dialect of Lisp that’s embedded in Python.
- Loading branch information
1 parent
23a1ae5
commit 89f4885
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
;; Fibonacci example in Hy. | ||
|
||
(defn fib [n] | ||
(if (<= n 2) n | ||
(+ (fib (- n 1)) (fib (- n 2))))) | ||
|
||
(if (= __name__ "__main__") | ||
(for [x [1 2 3 4 5 6 7 8]] | ||
(print (fib x)))) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
;; The concurrent.futures example in Hy. | ||
|
||
(import [concurrent.futures [ThreadPoolExecutor as-completed]] | ||
[random [randint]] | ||
[sh [sleep]]) | ||
|
||
(defn task-to-do [] | ||
(sleep (randint 1 5))) | ||
|
||
(with-as (ThreadPoolExecutor 10) executor | ||
(setv jobs (list-comp (.submit executor task-to-do) (x (range 0 10)))) | ||
(for (future (as-completed jobs)) | ||
(.result future))) |