(ns cljrs.compiler.known)
(def known-fns
{"vector" :vector
"hash-map" :hash-map
"hash-set" :hash-set
"list" :list
"assoc" :assoc
"dissoc" :dissoc
"conj" :conj
"disj" :disj
"get" :get
"nth" :nth
"count" :count
"contains?" :contains
"transient" :transient
"assoc!" :assoc!
"conj!" :conj!
"persistent!" :persistent!
"first" :first
"rest" :rest
"next" :next
"cons" :cons
"seq" :seq
"lazy-seq" :lazy-seq
"+" :+
"-" :-
"*" :*
"/" :/
"rem" :rem
"mod" :rem
"=" :=
"<" :<
">" :>
"<=" :<=
">=" :>=
"nil?" :nil?
"seq?" :seq?
"vector?" :vector?
"map?" :map?
"identical?" :identical?
"str" :str
"deref" :deref
"println" :println
"pr" :pr
"apply" :apply
"reduce" :reduce
"map" :map
"filter" :filter
"mapv" :mapv
"filterv" :filterv
"some" :some
"every?" :every?
"into" :into
"concat" :concat
"range" :range
"take" :take
"drop" :drop
"reverse" :reverse
"sort" :sort
"sort-by" :sort-by
"keys" :keys
"vals" :vals
"merge" :merge
"update" :update
"get-in" :get-in
"assoc-in" :assoc-in
"number?" :number?
"string?" :string?
"keyword?" :keyword?
"symbol?" :symbol?
"boolean?" :boolean?
"int?" :int?
"prn" :prn
"print" :print
"atom" :atom
"reset!" :atom-reset
"swap!" :atom-swap
"make-lazy-seq" :lazy-seq
"group-by" :group-by
"partition" :partition
"frequencies" :frequencies
"keep" :keep
"remove" :remove
"map-indexed" :map-indexed
"zipmap" :zipmap
"juxt" :juxt
"comp" :comp
"partial" :partial
"complement" :complement})
(defn strip-ns-prefix
[s]
(if (= s "/")
s
(loop [i (- (count s) 1)]
(if (< i 0)
s
(if (= (nth s i) \/)
(subs s (+ i 1))
(recur (- i 1)))))))
(defn resolve-known-fn
"Resolve a symbol name to a KnownFn keyword, or nil if not known.
Strips namespace prefix for core functions."
[sym-name]
(get known-fns (strip-ns-prefix sym-name)))