Shadow get
(#1344)
This commit is contained in:
parent
0a14410911
commit
67a4815024
1
NEWS
1
NEWS
@ -12,6 +12,7 @@ Changes from 0.13.0
|
||||
as necessary, so you can write ``(eval `(+ 1 ~n))`` instead of
|
||||
``(eval `(+ 1 ~(HyInteger n)))``
|
||||
* Literal `Inf`s and `NaN`s must now be capitalized like that
|
||||
* `get` is available as a function
|
||||
|
||||
[ Bug Fixes ]
|
||||
* Numeric literals are no longer parsed as symbols when followed by a dot
|
||||
|
@ -138,11 +138,18 @@
|
||||
(defn not-in [x y]
|
||||
(not-in x y))
|
||||
|
||||
(defn get [coll key1 &rest keys]
|
||||
(setv coll (get coll key1))
|
||||
(for* [k keys]
|
||||
(setv coll (get coll k)))
|
||||
coll)
|
||||
|
||||
(setv *exports* [
|
||||
'+ '- '* '** '/ '// '% '@
|
||||
'<< '>> '& '| '^ '~
|
||||
'< '> '<= '>= '= '!=
|
||||
'and 'or 'not
|
||||
'is 'is-not 'in 'not-in])
|
||||
'is 'is-not 'in 'not-in
|
||||
'get])
|
||||
(if (not PY35)
|
||||
(.remove *exports* '@))
|
||||
|
@ -288,3 +288,11 @@
|
||||
(assert (is (f 3 [1 2]) (!= f-name "in")))
|
||||
(assert (is (f 2 [1 2]) (= f-name "in")))
|
||||
(forbid (f 2 [1 2] [3 4])))
|
||||
|
||||
|
||||
(op-and-shadow-test [get]
|
||||
(forbid (f))
|
||||
(forbid (f "hello"))
|
||||
(assert (= (f "hello" 1) "e"))
|
||||
(assert (= (f [[1 2 3] [4 5 6] [7 8 9]] 1 2) 6))
|
||||
(assert (= (f {"x" {"y" {"z" 12}}} "x" "y" "z") 12)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user