From 89f4885b629c2da0eb2333010a1770a18a94d853 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sat, 14 Dec 2013 10:43:08 +0200 Subject: [PATCH] Add Hy language. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hy is a dialect of Lisp that’s embedded in Python. --- lib/linguist/languages.yml | 7 +++++++ samples/Hy/fibonacci.hy | 9 +++++++++ samples/Hy/hello-world.hy | 13 +++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 samples/Hy/fibonacci.hy create mode 100644 samples/Hy/hello-world.hy diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 856f146d..a3b84466 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -733,6 +733,13 @@ Haxe: extensions: - .hxsl +Hy: + type: programming + lexer: Clojure + ace_mode: clojure + color: "#7891b1" + primary_extension: .hy + IDL: type: programming lexer: Text only diff --git a/samples/Hy/fibonacci.hy b/samples/Hy/fibonacci.hy new file mode 100644 index 00000000..9ccdd76c --- /dev/null +++ b/samples/Hy/fibonacci.hy @@ -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)))) diff --git a/samples/Hy/hello-world.hy b/samples/Hy/hello-world.hy new file mode 100644 index 00000000..181095e1 --- /dev/null +++ b/samples/Hy/hello-world.hy @@ -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)))