diff --git a/host/chez/seq.ss b/host/chez/seq.ss index 7ac020a..98401ad 100644 --- a/host/chez/seq.ss +++ b/host/chez/seq.ss @@ -161,6 +161,7 @@ (cond ((procedure? f) (apply f args)) ((keyword? f) (apply jolt-get (car args) f (cdr args))) ; (:k m [d]) -> (get m :k [d]) + ((jolt-symbol? f) (apply jolt-get (car args) f (cdr args))) ; ('s m [d]) -> (get m 's [d]) ((jolt-coll? f) (apply jolt-get f args)) ; (coll k [d]) -> (get coll k [d]) ((jolt-transient? f) (apply jolt-get f args)) ; a transient vec/map/set is callable on the JVM ;; a record/reify implementing clojure.lang.IFn is callable: dispatch to its diff --git a/test/chez/corpus.edn b/test/chez/corpus.edn index 67b70b7..c880e4b 100644 --- a/test/chez/corpus.edn +++ b/test/chez/corpus.edn @@ -3293,4 +3293,7 @@ {:suite "seqs / lazy-seq interop" :label "empty? of an empty rest" :expected "true" :actual "(empty? (rest [1]))"} {:suite "seqs / lazy-seq interop" :label "cons onto a rest-seq" :expected "true" :actual "(= [0 2 3] (vec (cons 0 (rest [1 2 3]))))"} {:suite "seqs / lazy-seq interop" :label "into a set from a rest-seq" :expected "true" :actual "(= #{2 3} (into #{} (rest [1 2 3])))"} + {:suite "ifn / symbol as fn" :label "a symbol invokes as a map lookup" :expected "true" :actual "(= 5 ('a {(quote a) 5}))"} + {:suite "ifn / symbol as fn" :label "a symbol fn takes a not-found default" :expected "true" :actual "(= :d ('a {} :d))"} + {:suite "ifn / symbol as fn" :label "a symbol works as a mapping fn" :expected "true" :actual "(= [1 2] (vec (map (quote k) [{(quote k) 1} {(quote k) 2}])))"} ]