Navigation Menu

Skip to content

Commit

Permalink
ruby: Add number?, fn?, macro?
Browse files Browse the repository at this point in the history
  • Loading branch information
dubek committed Oct 9, 2017
1 parent 59436f1 commit 2e13db6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ruby/core.rb
Expand Up @@ -13,6 +13,9 @@
:symbol? => lambda {|a| a.is_a? Symbol},
:keyword => lambda {|a| "\u029e"+a},
:keyword? => lambda {|a| (a.is_a? String) && "\u029e" == a[0]},
:number? => lambda {|a| a.is_a? Numeric},
:fn? => lambda {|a| (a.is_a? Proc) && (!(a.is_a? Function) || !a.is_macro)},
:macro? => lambda {|a| (a.is_a? Function) && a.is_macro},

:"pr-str" => lambda {|*a| a.map {|e| _pr_str(e, true)}.join(" ")},
:str => lambda {|*a| a.map {|e| _pr_str(e, false)}.join("")},
Expand Down
7 changes: 7 additions & 0 deletions ruby/suggest.mal
@@ -0,0 +1,7 @@
(def! read-args (fn* [args]
(let* [arg (readline "arg> ")]
(if (or (nil? arg) (empty? arg))
args
(read-args (conj args arg))))))

(prn "The args you entered are:" (read-args []))

0 comments on commit 2e13db6

Please sign in to comment.