Skip to content

Commit

Permalink
Add number?, fn?, macro? in stepA - tests and process guide
Browse files Browse the repository at this point in the history
Ref #298
  • Loading branch information
dubek committed Oct 9, 2017
1 parent e05815a commit 59436f1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions process/guide.md
Expand Up @@ -1635,6 +1635,10 @@ For extra information read [Peter Seibel's thorough discussion about
new vector is returned with the elements added to the end of the
given vector.
* `string?`: returns true if the parameter is a string.
* `number?`: returns true if the parameter is a number.
* `fn?`: returns true if the parameter is a function (internal or
user-defined).
* `macro?`: returns true if the parameter is a macro.
* `seq`: takes a list, vector, string, or nil. If an empty list,
empty vector, or empty string ("") is passed in then nil is
returned. Otherwise, a list is returned unchanged, a vector is
Expand Down
3 changes: 3 additions & 0 deletions process/stepA_mal.txt
Expand Up @@ -87,6 +87,9 @@ ns = {'=: equal?,
'symbol?: symbol?,
'keyword: keyword,
'keyword?: keyword?,
'number?: number?,
'fn?: fn?,
'macro?: macro?,

'pr-str: (a) -> a.map(|s| pr_str(e,true)).join(" ")),
'str: (a) -> a.map(|s| pr_str(e,false)).join("")),
Expand Down
41 changes: 41 additions & 0 deletions tests/stepA_mal.mal
Expand Up @@ -96,6 +96,47 @@
(get @e "bar")
;=>(1 2 3)

;; ------------------------------------------------------------------
;; TODO move these to optional functionality after adding them to all
;; implementations
;;
;; Testing string? function
(number? 123)
;=>true
(number? -1)
;=>true
(number? nil)
;=>false
(number? false)
;=>false
(number? "123")
;=>false

;; Testing fn? function
(fn? +)
;=>true
(fn? not)
;=>true
(fn? cond)
;=>false
(fn? "+")
;=>false
(fn? :+)
;=>false

;; Testing macro? function
(macro? cond)
;=>true
(macro? +)
;=>false
(macro? not)
;=>false
(macro? "+")
;=>false
(macro? :+)
;=>false

;; ------------------------------------------------------------------

;>>> soft=True
;>>> optional=True
Expand Down

0 comments on commit 59436f1

Please sign in to comment.