fix bugs in page
This commit is contained in:
1 parent
6ed638a1cc
commit
e654fdfea6
387 files changed
+13618
-88879
No files matched your search
@@ -0,0 +1,161 @@
|
||||
; Copyright (c) Rich Hickey. All rights reserved.
|
||||
; The use and distribution terms for this software are covered by the
|
||||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
; By using this software in any fashion, you are agreeing to be bound by
|
||||
; the terms of this license.
|
||||
; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns ^{:doc "Set operations such as union/intersection."
|
||||
:author "Rich Hickey"}
|
||||
clojure.set)
|
||||
|
||||
(defn- bubble-max-key [k coll]
|
||||
"Move a maximal element of coll according to fn k (which returns a number)
|
||||
to the front of coll."
|
||||
(let [max (apply max-key k coll)]
|
||||
(cons max (remove #(identical? max %) coll))))
|
||||
|
||||
(defn union
|
||||
"Return a set that is the union of the input sets"
|
||||
([] #{})
|
||||
([s1] s1)
|
||||
([s1 s2]
|
||||
(if (< (count s1) (count s2))
|
||||
(reduce conj s2 s1)
|
||||
(reduce conj s1 s2)))
|
||||
([s1 s2 & sets]
|
||||
(let [bubbled-sets (bubble-max-key count (conj sets s2 s1))]
|
||||
(reduce into (first bubbled-sets) (rest bubbled-sets)))))
|
||||
|
||||
(defn intersection
|
||||
"Return a set that is the intersection of the input sets"
|
||||
([s1] s1)
|
||||
([s1 s2]
|
||||
(if (< (count s2) (count s1))
|
||||
(recur s2 s1)
|
||||
(reduce (fn [result item]
|
||||
(if (contains? s2 item)
|
||||
result
|
||||
(disj result item)))
|
||||
s1 s1)))
|
||||
([s1 s2 & sets]
|
||||
(let [bubbled-sets (bubble-max-key #(- (count %)) (conj sets s2 s1))]
|
||||
(reduce intersection (first bubbled-sets) (rest bubbled-sets)))))
|
||||
|
||||
(defn difference
|
||||
"Return a set that is the first set without elements of the remaining sets"
|
||||
([s1] s1)
|
||||
([s1 s2]
|
||||
(if (< (count s1) (count s2))
|
||||
(reduce (fn [result item]
|
||||
(if (contains? s2 item)
|
||||
(disj result item)
|
||||
result))
|
||||
s1 s1)
|
||||
(reduce disj s1 s2)))
|
||||
([s1 s2 & sets]
|
||||
(reduce difference s1 (conj sets s2))))
|
||||
|
||||
|
||||
(defn select
|
||||
"Returns a set of the elements for which pred is true"
|
||||
[pred xset]
|
||||
(reduce (fn [s k] (if (pred k) s (disj s k)))
|
||||
xset xset))
|
||||
|
||||
(defn project
|
||||
"Returns a rel of the elements of xrel with only the keys in ks"
|
||||
[xrel ks]
|
||||
(set (map #(select-keys % ks) xrel)))
|
||||
|
||||
(defn rename-keys
|
||||
"Returns the map with the keys in kmap renamed to the vals in kmap"
|
||||
[map kmap]
|
||||
(reduce
|
||||
(fn [m [old new]]
|
||||
(if (contains? map old)
|
||||
(assoc m new (get map old))
|
||||
m))
|
||||
(apply dissoc map (keys kmap)) kmap))
|
||||
|
||||
(defn rename
|
||||
"Returns a rel of the maps in xrel with the keys in kmap renamed to the vals in kmap"
|
||||
[xrel kmap]
|
||||
(set (map #(rename-keys % kmap) xrel)))
|
||||
|
||||
(defn index
|
||||
"Returns a map of the distinct values of ks in the xrel mapped to a
|
||||
set of the maps in xrel with the corresponding values of ks."
|
||||
[xrel ks]
|
||||
(reduce
|
||||
(fn [m x]
|
||||
(let [ik (select-keys x ks)]
|
||||
(assoc m ik (conj (get m ik #{}) x))))
|
||||
{} xrel))
|
||||
|
||||
(defn map-invert
|
||||
"Returns the map with the vals mapped to the keys."
|
||||
[m] (reduce (fn [m [k v]] (assoc m v k)) {} m))
|
||||
|
||||
(defn join
|
||||
"When passed 2 rels, returns the rel corresponding to the natural
|
||||
join. When passed an additional keymap, joins on the corresponding
|
||||
keys."
|
||||
([xrel yrel] ;natural join
|
||||
(if (and (seq xrel) (seq yrel))
|
||||
(let [ks (intersection (set (keys (first xrel))) (set (keys (first yrel))))
|
||||
[r s] (if (<= (count xrel) (count yrel))
|
||||
[xrel yrel]
|
||||
[yrel xrel])
|
||||
idx (index r ks)]
|
||||
(reduce (fn [ret x]
|
||||
(let [found (idx (select-keys x ks))]
|
||||
(if found
|
||||
(reduce #(conj %1 (merge %2 x)) ret found)
|
||||
ret)))
|
||||
#{} s))
|
||||
#{}))
|
||||
([xrel yrel km] ;arbitrary key mapping
|
||||
(let [[r s k] (if (<= (count xrel) (count yrel))
|
||||
[xrel yrel (map-invert km)]
|
||||
[yrel xrel km])
|
||||
idx (index r (vals k))]
|
||||
(reduce (fn [ret x]
|
||||
(let [found (idx (rename-keys (select-keys x (keys k)) k))]
|
||||
(if found
|
||||
(reduce #(conj %1 (merge %2 x)) ret found)
|
||||
ret)))
|
||||
#{} s))))
|
||||
|
||||
(defn subset?
|
||||
"Is set1 a subset of set2?"
|
||||
[set1 set2]
|
||||
(and (<= (count set1) (count set2))
|
||||
(every? #(contains? set2 %) set1)))
|
||||
|
||||
(defn superset?
|
||||
"Is set1 a superset of set2?"
|
||||
[set1 set2]
|
||||
(and (>= (count set1) (count set2))
|
||||
(every? #(contains? set1 %) set2)))
|
||||
|
||||
(comment
|
||||
(refer 'set)
|
||||
(def xs #{{:a 11 :b 1 :c 1 :d 4}
|
||||
{:a 2 :b 12 :c 2 :d 6}
|
||||
{:a 3 :b 3 :c 3 :d 8 :f 42}})
|
||||
|
||||
(def ys #{{:a 11 :b 11 :c 11 :e 5}
|
||||
{:a 12 :b 11 :c 12 :e 3}
|
||||
{:a 3 :b 3 :c 3 :e 7 }})
|
||||
|
||||
(join xs ys)
|
||||
(join xs (rename ys {:b :yb :c :yc}) {:a :a})
|
||||
|
||||
(union #{:a :b :c} #{:c :d :e })
|
||||
(difference #{:a :b :c} #{:c :d :e})
|
||||
(intersection #{:a :b :c} #{:c :d :e})
|
||||
|
||||
(index ys [:b]))
|
||||
|
||||
@@ -0,0 +1,388 @@
|
||||
// Compiled by ClojureScript 1.9.946 {:static-fns true, :optimize-constants true}
|
||||
goog.provide('clojure.set');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
clojure.set.bubble_max_key = (function clojure$set$bubble_max_key(k,coll){
|
||||
|
||||
var max = cljs.core.apply.cljs$core$IFn$_invoke$arity$3(cljs.core.max_key,k,coll);
|
||||
return cljs.core.cons(max,cljs.core.remove.cljs$core$IFn$_invoke$arity$2(((function (max){
|
||||
return (function (p1__14548_SHARP_){
|
||||
return (max === p1__14548_SHARP_);
|
||||
});})(max))
|
||||
,coll));
|
||||
});
|
||||
/**
|
||||
* Return a set that is the union of the input sets
|
||||
*/
|
||||
clojure.set.union = (function clojure$set$union(var_args){
|
||||
var G__14553 = arguments.length;
|
||||
switch (G__14553) {
|
||||
case 0:
|
||||
return clojure.set.union.cljs$core$IFn$_invoke$arity$0();
|
||||
|
||||
break;
|
||||
case 1:
|
||||
return clojure.set.union.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return clojure.set.union.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
var args_arr__10084__auto__ = [];
|
||||
var len__10061__auto___14555 = arguments.length;
|
||||
var i__10062__auto___14556 = (0);
|
||||
while(true){
|
||||
if((i__10062__auto___14556 < len__10061__auto___14555)){
|
||||
args_arr__10084__auto__.push((arguments[i__10062__auto___14556]));
|
||||
|
||||
var G__14557 = (i__10062__auto___14556 + (1));
|
||||
i__10062__auto___14556 = G__14557;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__10085__auto__ = (new cljs.core.IndexedSeq(args_arr__10084__auto__.slice((2)),(0),null));
|
||||
return clojure.set.union.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__10085__auto__);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$core$IFn$_invoke$arity$0 = (function (){
|
||||
return cljs.core.PersistentHashSet.EMPTY;
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$core$IFn$_invoke$arity$1 = (function (s1){
|
||||
return s1;
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$core$IFn$_invoke$arity$2 = (function (s1,s2){
|
||||
if((cljs.core.count(s1) < cljs.core.count(s2))){
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core.conj,s2,s1);
|
||||
} else {
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core.conj,s1,s2);
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$core$IFn$_invoke$arity$variadic = (function (s1,s2,sets){
|
||||
var bubbled_sets = clojure.set.bubble_max_key(cljs.core.count,cljs.core.conj.cljs$core$IFn$_invoke$arity$variadic(sets,s2,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([s1], 0)));
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core.into,cljs.core.first(bubbled_sets),cljs.core.rest(bubbled_sets));
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$lang$applyTo = (function (seq14550){
|
||||
var G__14551 = cljs.core.first(seq14550);
|
||||
var seq14550__$1 = cljs.core.next(seq14550);
|
||||
var G__14552 = cljs.core.first(seq14550__$1);
|
||||
var seq14550__$2 = cljs.core.next(seq14550__$1);
|
||||
return clojure.set.union.cljs$core$IFn$_invoke$arity$variadic(G__14551,G__14552,seq14550__$2);
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$lang$maxFixedArity = (2);
|
||||
|
||||
/**
|
||||
* Return a set that is the intersection of the input sets
|
||||
*/
|
||||
clojure.set.intersection = (function clojure$set$intersection(var_args){
|
||||
var G__14563 = arguments.length;
|
||||
switch (G__14563) {
|
||||
case 1:
|
||||
return clojure.set.intersection.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return clojure.set.intersection.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
var args_arr__10084__auto__ = [];
|
||||
var len__10061__auto___14565 = arguments.length;
|
||||
var i__10062__auto___14566 = (0);
|
||||
while(true){
|
||||
if((i__10062__auto___14566 < len__10061__auto___14565)){
|
||||
args_arr__10084__auto__.push((arguments[i__10062__auto___14566]));
|
||||
|
||||
var G__14567 = (i__10062__auto___14566 + (1));
|
||||
i__10062__auto___14566 = G__14567;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__10085__auto__ = (new cljs.core.IndexedSeq(args_arr__10084__auto__.slice((2)),(0),null));
|
||||
return clojure.set.intersection.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__10085__auto__);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.intersection.cljs$core$IFn$_invoke$arity$1 = (function (s1){
|
||||
return s1;
|
||||
});
|
||||
|
||||
clojure.set.intersection.cljs$core$IFn$_invoke$arity$2 = (function (s1,s2){
|
||||
while(true){
|
||||
if((cljs.core.count(s2) < cljs.core.count(s1))){
|
||||
var G__14568 = s2;
|
||||
var G__14569 = s1;
|
||||
s1 = G__14568;
|
||||
s2 = G__14569;
|
||||
continue;
|
||||
} else {
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(((function (s1,s2){
|
||||
return (function (result,item){
|
||||
if(cljs.core.contains_QMARK_(s2,item)){
|
||||
return result;
|
||||
} else {
|
||||
return cljs.core.disj.cljs$core$IFn$_invoke$arity$2(result,item);
|
||||
}
|
||||
});})(s1,s2))
|
||||
,s1,s1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.intersection.cljs$core$IFn$_invoke$arity$variadic = (function (s1,s2,sets){
|
||||
var bubbled_sets = clojure.set.bubble_max_key((function (p1__14558_SHARP_){
|
||||
return (- cljs.core.count(p1__14558_SHARP_));
|
||||
}),cljs.core.conj.cljs$core$IFn$_invoke$arity$variadic(sets,s2,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([s1], 0)));
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(clojure.set.intersection,cljs.core.first(bubbled_sets),cljs.core.rest(bubbled_sets));
|
||||
});
|
||||
|
||||
clojure.set.intersection.cljs$lang$applyTo = (function (seq14560){
|
||||
var G__14561 = cljs.core.first(seq14560);
|
||||
var seq14560__$1 = cljs.core.next(seq14560);
|
||||
var G__14562 = cljs.core.first(seq14560__$1);
|
||||
var seq14560__$2 = cljs.core.next(seq14560__$1);
|
||||
return clojure.set.intersection.cljs$core$IFn$_invoke$arity$variadic(G__14561,G__14562,seq14560__$2);
|
||||
});
|
||||
|
||||
clojure.set.intersection.cljs$lang$maxFixedArity = (2);
|
||||
|
||||
/**
|
||||
* Return a set that is the first set without elements of the remaining sets
|
||||
*/
|
||||
clojure.set.difference = (function clojure$set$difference(var_args){
|
||||
var G__14574 = arguments.length;
|
||||
switch (G__14574) {
|
||||
case 1:
|
||||
return clojure.set.difference.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return clojure.set.difference.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
var args_arr__10084__auto__ = [];
|
||||
var len__10061__auto___14576 = arguments.length;
|
||||
var i__10062__auto___14577 = (0);
|
||||
while(true){
|
||||
if((i__10062__auto___14577 < len__10061__auto___14576)){
|
||||
args_arr__10084__auto__.push((arguments[i__10062__auto___14577]));
|
||||
|
||||
var G__14578 = (i__10062__auto___14577 + (1));
|
||||
i__10062__auto___14577 = G__14578;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__10085__auto__ = (new cljs.core.IndexedSeq(args_arr__10084__auto__.slice((2)),(0),null));
|
||||
return clojure.set.difference.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__10085__auto__);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.difference.cljs$core$IFn$_invoke$arity$1 = (function (s1){
|
||||
return s1;
|
||||
});
|
||||
|
||||
clojure.set.difference.cljs$core$IFn$_invoke$arity$2 = (function (s1,s2){
|
||||
if((cljs.core.count(s1) < cljs.core.count(s2))){
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (result,item){
|
||||
if(cljs.core.contains_QMARK_(s2,item)){
|
||||
return cljs.core.disj.cljs$core$IFn$_invoke$arity$2(result,item);
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}),s1,s1);
|
||||
} else {
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core.disj,s1,s2);
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.difference.cljs$core$IFn$_invoke$arity$variadic = (function (s1,s2,sets){
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(clojure.set.difference,s1,cljs.core.conj.cljs$core$IFn$_invoke$arity$2(sets,s2));
|
||||
});
|
||||
|
||||
clojure.set.difference.cljs$lang$applyTo = (function (seq14571){
|
||||
var G__14572 = cljs.core.first(seq14571);
|
||||
var seq14571__$1 = cljs.core.next(seq14571);
|
||||
var G__14573 = cljs.core.first(seq14571__$1);
|
||||
var seq14571__$2 = cljs.core.next(seq14571__$1);
|
||||
return clojure.set.difference.cljs$core$IFn$_invoke$arity$variadic(G__14572,G__14573,seq14571__$2);
|
||||
});
|
||||
|
||||
clojure.set.difference.cljs$lang$maxFixedArity = (2);
|
||||
|
||||
/**
|
||||
* Returns a set of the elements for which pred is true
|
||||
*/
|
||||
clojure.set.select = (function clojure$set$select(pred,xset){
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (s,k){
|
||||
if(cljs.core.truth_((pred.cljs$core$IFn$_invoke$arity$1 ? pred.cljs$core$IFn$_invoke$arity$1(k) : pred.call(null,k)))){
|
||||
return s;
|
||||
} else {
|
||||
return cljs.core.disj.cljs$core$IFn$_invoke$arity$2(s,k);
|
||||
}
|
||||
}),xset,xset);
|
||||
});
|
||||
/**
|
||||
* Returns a rel of the elements of xrel with only the keys in ks
|
||||
*/
|
||||
clojure.set.project = (function clojure$set$project(xrel,ks){
|
||||
return cljs.core.set(cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (p1__14579_SHARP_){
|
||||
return cljs.core.select_keys(p1__14579_SHARP_,ks);
|
||||
}),xrel));
|
||||
});
|
||||
/**
|
||||
* Returns the map with the keys in kmap renamed to the vals in kmap
|
||||
*/
|
||||
clojure.set.rename_keys = (function clojure$set$rename_keys(map,kmap){
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (m,p__14580){
|
||||
var vec__14581 = p__14580;
|
||||
var old = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14581,(0),null);
|
||||
var new$ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14581,(1),null);
|
||||
if(cljs.core.contains_QMARK_(map,old)){
|
||||
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(m,new$,cljs.core.get.cljs$core$IFn$_invoke$arity$2(map,old));
|
||||
} else {
|
||||
return m;
|
||||
}
|
||||
}),cljs.core.apply.cljs$core$IFn$_invoke$arity$3(cljs.core.dissoc,map,cljs.core.keys(kmap)),kmap);
|
||||
});
|
||||
/**
|
||||
* Returns a rel of the maps in xrel with the keys in kmap renamed to the vals in kmap
|
||||
*/
|
||||
clojure.set.rename = (function clojure$set$rename(xrel,kmap){
|
||||
return cljs.core.set(cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (p1__14584_SHARP_){
|
||||
return clojure.set.rename_keys(p1__14584_SHARP_,kmap);
|
||||
}),xrel));
|
||||
});
|
||||
/**
|
||||
* Returns a map of the distinct values of ks in the xrel mapped to a
|
||||
* set of the maps in xrel with the corresponding values of ks.
|
||||
*/
|
||||
clojure.set.index = (function clojure$set$index(xrel,ks){
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (m,x){
|
||||
var ik = cljs.core.select_keys(x,ks);
|
||||
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(m,ik,cljs.core.conj.cljs$core$IFn$_invoke$arity$2(cljs.core.get.cljs$core$IFn$_invoke$arity$3(m,ik,cljs.core.PersistentHashSet.EMPTY),x));
|
||||
}),cljs.core.PersistentArrayMap.EMPTY,xrel);
|
||||
});
|
||||
/**
|
||||
* Returns the map with the vals mapped to the keys.
|
||||
*/
|
||||
clojure.set.map_invert = (function clojure$set$map_invert(m){
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (m__$1,p__14585){
|
||||
var vec__14586 = p__14585;
|
||||
var k = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14586,(0),null);
|
||||
var v = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14586,(1),null);
|
||||
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(m__$1,v,k);
|
||||
}),cljs.core.PersistentArrayMap.EMPTY,m);
|
||||
});
|
||||
/**
|
||||
* When passed 2 rels, returns the rel corresponding to the natural
|
||||
* join. When passed an additional keymap, joins on the corresponding
|
||||
* keys.
|
||||
*/
|
||||
clojure.set.join = (function clojure$set$join(var_args){
|
||||
var G__14594 = arguments.length;
|
||||
switch (G__14594) {
|
||||
case 2:
|
||||
return clojure.set.join.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.set.join.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.join.cljs$core$IFn$_invoke$arity$2 = (function (xrel,yrel){
|
||||
if((cljs.core.seq(xrel)) && (cljs.core.seq(yrel))){
|
||||
var ks = clojure.set.intersection.cljs$core$IFn$_invoke$arity$2(cljs.core.set(cljs.core.keys(cljs.core.first(xrel))),cljs.core.set(cljs.core.keys(cljs.core.first(yrel))));
|
||||
var vec__14595 = (((cljs.core.count(xrel) <= cljs.core.count(yrel)))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [xrel,yrel], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [yrel,xrel], null));
|
||||
var r = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14595,(0),null);
|
||||
var s = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14595,(1),null);
|
||||
var idx = clojure.set.index(r,ks);
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(((function (ks,vec__14595,r,s,idx){
|
||||
return (function (ret,x){
|
||||
var found = (function (){var G__14598 = cljs.core.select_keys(x,ks);
|
||||
return (idx.cljs$core$IFn$_invoke$arity$1 ? idx.cljs$core$IFn$_invoke$arity$1(G__14598) : idx.call(null,G__14598));
|
||||
})();
|
||||
if(cljs.core.truth_(found)){
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(((function (found,ks,vec__14595,r,s,idx){
|
||||
return (function (p1__14589_SHARP_,p2__14590_SHARP_){
|
||||
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(p1__14589_SHARP_,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([p2__14590_SHARP_,x], 0)));
|
||||
});})(found,ks,vec__14595,r,s,idx))
|
||||
,ret,found);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
});})(ks,vec__14595,r,s,idx))
|
||||
,cljs.core.PersistentHashSet.EMPTY,s);
|
||||
} else {
|
||||
return cljs.core.PersistentHashSet.EMPTY;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.join.cljs$core$IFn$_invoke$arity$3 = (function (xrel,yrel,km){
|
||||
var vec__14599 = (((cljs.core.count(xrel) <= cljs.core.count(yrel)))?new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [xrel,yrel,clojure.set.map_invert(km)], null):new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [yrel,xrel,km], null));
|
||||
var r = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14599,(0),null);
|
||||
var s = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14599,(1),null);
|
||||
var k = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14599,(2),null);
|
||||
var idx = clojure.set.index(r,cljs.core.vals(k));
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(((function (vec__14599,r,s,k,idx){
|
||||
return (function (ret,x){
|
||||
var found = (function (){var G__14602 = clojure.set.rename_keys(cljs.core.select_keys(x,cljs.core.keys(k)),k);
|
||||
return (idx.cljs$core$IFn$_invoke$arity$1 ? idx.cljs$core$IFn$_invoke$arity$1(G__14602) : idx.call(null,G__14602));
|
||||
})();
|
||||
if(cljs.core.truth_(found)){
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(((function (found,vec__14599,r,s,k,idx){
|
||||
return (function (p1__14591_SHARP_,p2__14592_SHARP_){
|
||||
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(p1__14591_SHARP_,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([p2__14592_SHARP_,x], 0)));
|
||||
});})(found,vec__14599,r,s,k,idx))
|
||||
,ret,found);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
});})(vec__14599,r,s,k,idx))
|
||||
,cljs.core.PersistentHashSet.EMPTY,s);
|
||||
});
|
||||
|
||||
clojure.set.join.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* Is set1 a subset of set2?
|
||||
*/
|
||||
clojure.set.subset_QMARK_ = (function clojure$set$subset_QMARK_(set1,set2){
|
||||
return ((cljs.core.count(set1) <= cljs.core.count(set2))) && (cljs.core.every_QMARK_((function (p1__14604_SHARP_){
|
||||
return cljs.core.contains_QMARK_(set2,p1__14604_SHARP_);
|
||||
}),set1));
|
||||
});
|
||||
/**
|
||||
* Is set1 a superset of set2?
|
||||
*/
|
||||
clojure.set.superset_QMARK_ = (function clojure$set$superset_QMARK_(set1,set2){
|
||||
return ((cljs.core.count(set1) >= cljs.core.count(set2))) && (cljs.core.every_QMARK_((function (p1__14605_SHARP_){
|
||||
return cljs.core.contains_QMARK_(set1,p1__14605_SHARP_);
|
||||
}),set2));
|
||||
});
|
||||
@@ -0,0 +1,260 @@
|
||||
; Copyright (c) Rich Hickey. All rights reserved.
|
||||
; The use and distribution terms for this software are covered by the
|
||||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
; By using this software in any fashion, you are agreeing to be bound by
|
||||
; the terms of this license.
|
||||
; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns clojure.string
|
||||
(:refer-clojure :exclude [replace reverse])
|
||||
(:require [goog.string :as gstring])
|
||||
(:import [goog.string StringBuffer]))
|
||||
|
||||
(defn- seq-reverse
|
||||
[coll]
|
||||
(reduce conj () coll))
|
||||
|
||||
(def ^:private re-surrogate-pair
|
||||
(js/RegExp. "([\\uD800-\\uDBFF])([\\uDC00-\\uDFFF])" "g"))
|
||||
|
||||
(defn reverse
|
||||
"Returns s with its characters reversed."
|
||||
[s]
|
||||
(-> (.replace s re-surrogate-pair "$2$1")
|
||||
(.. (split "") (reverse) (join ""))))
|
||||
|
||||
(defn- replace-all
|
||||
[s re replacement]
|
||||
(let [r (js/RegExp. (.-source re)
|
||||
(cond-> "g"
|
||||
(.-ignoreCase re) (str "i")
|
||||
(.-multiline re) (str "m")
|
||||
(.-unicode re) (str "u")))]
|
||||
(.replace s r replacement)))
|
||||
|
||||
(defn- replace-with
|
||||
[f]
|
||||
(fn [& args]
|
||||
(let [matches (drop-last 2 args)]
|
||||
(if (= (count matches) 1)
|
||||
(f (first matches))
|
||||
(f (vec matches))))))
|
||||
|
||||
(defn replace
|
||||
"Replaces all instance of match with replacement in s.
|
||||
match/replacement can be:
|
||||
|
||||
string / string
|
||||
pattern / (string or function of match)."
|
||||
[s match replacement]
|
||||
(cond
|
||||
(string? match)
|
||||
(.replace s (js/RegExp. (gstring/regExpEscape match) "g") replacement)
|
||||
|
||||
(instance? js/RegExp match)
|
||||
(if (string? replacement)
|
||||
(replace-all s match replacement)
|
||||
(replace-all s match (replace-with replacement)))
|
||||
|
||||
:else (throw (str "Invalid match arg: " match))))
|
||||
|
||||
(defn replace-first
|
||||
"Replaces the first instance of match with replacement in s.
|
||||
match/replacement can be:
|
||||
|
||||
string / string
|
||||
pattern / (string or function of match)."
|
||||
[s match replacement]
|
||||
(.replace s match replacement))
|
||||
|
||||
(defn join
|
||||
"Returns a string of all elements in coll, as returned by (seq coll),
|
||||
separated by an optional separator."
|
||||
([coll]
|
||||
(loop [sb (StringBuffer.) coll (seq coll)]
|
||||
(if-not (nil? coll)
|
||||
(recur (. sb (append (str (first coll)))) (next coll))
|
||||
(.toString sb))))
|
||||
([separator coll]
|
||||
(loop [sb (StringBuffer.) coll (seq coll)]
|
||||
(if-not (nil? coll)
|
||||
(do
|
||||
(. sb (append (str (first coll))))
|
||||
(let [coll (next coll)]
|
||||
(when-not (nil? coll)
|
||||
(. sb (append separator)))
|
||||
(recur sb coll)))
|
||||
(.toString sb)))))
|
||||
|
||||
(defn upper-case
|
||||
"Converts string to all upper-case."
|
||||
[s]
|
||||
(.toUpperCase s))
|
||||
|
||||
(defn lower-case
|
||||
"Converts string to all lower-case."
|
||||
[s]
|
||||
(.toLowerCase s))
|
||||
|
||||
(defn capitalize
|
||||
"Converts first character of the string to upper-case, all other
|
||||
characters to lower-case."
|
||||
[s]
|
||||
(gstring/capitalize s))
|
||||
|
||||
;; The JavaScript split function takes a limit argument but the return
|
||||
;; value is not the same as the Java split function.
|
||||
;;
|
||||
;; Java: (.split "a-b-c" #"-" 2) => ["a" "b-c"]
|
||||
;; JavaScript: (.split "a-b-c" #"-" 2) => ["a" "b"]
|
||||
;;
|
||||
;; For consistency, the three arg version has been implemented to
|
||||
;; mimic Java's behavior.
|
||||
|
||||
(defn- pop-last-while-empty
|
||||
[v]
|
||||
(loop [v v]
|
||||
(if (identical? "" (peek v))
|
||||
(recur (pop v))
|
||||
v)))
|
||||
|
||||
(defn- discard-trailing-if-needed
|
||||
[limit v]
|
||||
(if (and (== 0 limit) (< 1 (count v)))
|
||||
(pop-last-while-empty v)
|
||||
v))
|
||||
|
||||
(defn- split-with-empty-regex
|
||||
[s limit]
|
||||
(if (or (<= limit 0) (>= limit (+ 2 (count s))))
|
||||
(conj (vec (cons "" (map str (seq s)))) "")
|
||||
(condp == limit
|
||||
1 (vector s)
|
||||
2 (vector "" s)
|
||||
(let [c (- limit 2)]
|
||||
(conj (vec (cons "" (subvec (vec (map str (seq s))) 0 c))) (subs s c))))))
|
||||
|
||||
(defn split
|
||||
"Splits string on a regular expression. Optional argument limit is
|
||||
the maximum number of splits. Not lazy. Returns vector of the splits."
|
||||
([s re]
|
||||
(split s re 0))
|
||||
([s re limit]
|
||||
(discard-trailing-if-needed limit
|
||||
(if (identical? "/(?:)/" (str re))
|
||||
(split-with-empty-regex s limit)
|
||||
(if (< limit 1)
|
||||
(vec (.split (str s) re))
|
||||
(loop [s s
|
||||
limit limit
|
||||
parts []]
|
||||
(if (== 1 limit)
|
||||
(conj parts s)
|
||||
(let [m (re-find re s)]
|
||||
(if-not (nil? m)
|
||||
(let [index (.indexOf s m)]
|
||||
(recur (.substring s (+ index (count m)))
|
||||
(dec limit)
|
||||
(conj parts (.substring s 0 index))))
|
||||
(conj parts s))))))))))
|
||||
|
||||
(defn split-lines
|
||||
"Splits s on \n or \r\n."
|
||||
[s]
|
||||
(split s #"\n|\r\n"))
|
||||
|
||||
(defn trim
|
||||
"Removes whitespace from both ends of string."
|
||||
[s]
|
||||
(gstring/trim s))
|
||||
|
||||
(defn triml
|
||||
"Removes whitespace from the left side of string."
|
||||
[s]
|
||||
(gstring/trimLeft s))
|
||||
|
||||
(defn trimr
|
||||
"Removes whitespace from the right side of string."
|
||||
[s]
|
||||
(gstring/trimRight s))
|
||||
|
||||
(defn trim-newline
|
||||
"Removes all trailing newline \\n or return \\r characters from
|
||||
string. Similar to Perl's chomp."
|
||||
[s]
|
||||
(loop [index (.-length s)]
|
||||
(if (zero? index)
|
||||
""
|
||||
(let [ch (get s (dec index))]
|
||||
(if (or (identical? \newline ch)
|
||||
(identical? \return ch))
|
||||
(recur (dec index))
|
||||
(.substring s 0 index))))))
|
||||
|
||||
(defn ^boolean blank?
|
||||
"True is s is nil, empty, or contains only whitespace."
|
||||
[s]
|
||||
(gstring/isEmptySafe s))
|
||||
|
||||
(defn escape
|
||||
"Return a new string, using cmap to escape each character ch
|
||||
from s as follows:
|
||||
|
||||
If (cmap ch) is nil, append ch to the new string.
|
||||
If (cmap ch) is non-nil, append (str (cmap ch)) instead."
|
||||
[s cmap]
|
||||
(let [buffer (StringBuffer.)
|
||||
length (.-length s)]
|
||||
(loop [index 0]
|
||||
(if (== length index)
|
||||
(. buffer (toString))
|
||||
(let [ch (.charAt s index)
|
||||
replacement (get cmap ch)]
|
||||
(if-not (nil? replacement)
|
||||
(.append buffer (str replacement))
|
||||
(.append buffer ch))
|
||||
(recur (inc index)))))))
|
||||
|
||||
(defn index-of
|
||||
"Return index of value (string or char) in s, optionally searching
|
||||
forward from from-index or nil if not found."
|
||||
([s value]
|
||||
(let [result (.indexOf s value)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result)))
|
||||
([s value from-index]
|
||||
(let [result (.indexOf s value from-index)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result))))
|
||||
|
||||
(defn last-index-of
|
||||
"Return last index of value (string or char) in s, optionally
|
||||
searching backward from from-index or nil if not found."
|
||||
([s value]
|
||||
(let [result (.lastIndexOf s value)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result)))
|
||||
([s value from-index]
|
||||
(let [result (.lastIndexOf s value from-index)]
|
||||
(if (neg? result)
|
||||
nil
|
||||
result))))
|
||||
|
||||
(defn ^boolean starts-with?
|
||||
"True if s starts with substr."
|
||||
[s substr]
|
||||
(gstring/startsWith s substr))
|
||||
|
||||
(defn ^boolean ends-with?
|
||||
"True if s ends with substr."
|
||||
[s substr]
|
||||
(gstring/endsWith s substr))
|
||||
|
||||
(defn ^boolean includes?
|
||||
"True if s includes substr."
|
||||
[s substr]
|
||||
(gstring/contains s substr))
|
||||
@@ -0,0 +1,451 @@
|
||||
// Compiled by ClojureScript 1.9.946 {:static-fns true, :optimize-constants true}
|
||||
goog.provide('clojure.string');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
clojure.string.seq_reverse = (function clojure$string$seq_reverse(coll){
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core.conj,cljs.core.List.EMPTY,coll);
|
||||
});
|
||||
clojure.string.re_surrogate_pair = (new RegExp("([\\uD800-\\uDBFF])([\\uDC00-\\uDFFF])","g"));
|
||||
/**
|
||||
* Returns s with its characters reversed.
|
||||
*/
|
||||
clojure.string.reverse = (function clojure$string$reverse(s){
|
||||
return s.replace(clojure.string.re_surrogate_pair,"$2$1").split("").reverse().join("");
|
||||
});
|
||||
clojure.string.replace_all = (function clojure$string$replace_all(s,re,replacement){
|
||||
var r = (new RegExp(re.source,(function (){var G__14493 = "g";
|
||||
var G__14493__$1 = (cljs.core.truth_(re.ignoreCase)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__14493),"i"].join(''):G__14493);
|
||||
var G__14493__$2 = (cljs.core.truth_(re.multiline)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__14493__$1),"m"].join(''):G__14493__$1);
|
||||
if(cljs.core.truth_(re.unicode)){
|
||||
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__14493__$2),"u"].join('');
|
||||
} else {
|
||||
return G__14493__$2;
|
||||
}
|
||||
})()));
|
||||
return s.replace(r,replacement);
|
||||
});
|
||||
clojure.string.replace_with = (function clojure$string$replace_with(f){
|
||||
return (function() {
|
||||
var G__14496__delegate = function (args){
|
||||
var matches = cljs.core.drop_last.cljs$core$IFn$_invoke$arity$2((2),args);
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.count(matches),(1))){
|
||||
var G__14494 = cljs.core.first(matches);
|
||||
return (f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(G__14494) : f.call(null,G__14494));
|
||||
} else {
|
||||
var G__14495 = cljs.core.vec(matches);
|
||||
return (f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(G__14495) : f.call(null,G__14495));
|
||||
}
|
||||
};
|
||||
var G__14496 = function (var_args){
|
||||
var args = null;
|
||||
if (arguments.length > 0) {
|
||||
var G__14497__i = 0, G__14497__a = new Array(arguments.length - 0);
|
||||
while (G__14497__i < G__14497__a.length) {G__14497__a[G__14497__i] = arguments[G__14497__i + 0]; ++G__14497__i;}
|
||||
args = new cljs.core.IndexedSeq(G__14497__a,0,null);
|
||||
}
|
||||
return G__14496__delegate.call(this,args);};
|
||||
G__14496.cljs$lang$maxFixedArity = 0;
|
||||
G__14496.cljs$lang$applyTo = (function (arglist__14498){
|
||||
var args = cljs.core.seq(arglist__14498);
|
||||
return G__14496__delegate(args);
|
||||
});
|
||||
G__14496.cljs$core$IFn$_invoke$arity$variadic = G__14496__delegate;
|
||||
return G__14496;
|
||||
})()
|
||||
;
|
||||
});
|
||||
/**
|
||||
* Replaces all instance of match with replacement in s.
|
||||
* match/replacement can be:
|
||||
*
|
||||
* string / string
|
||||
* pattern / (string or function of match).
|
||||
*/
|
||||
clojure.string.replace = (function clojure$string$replace(s,match,replacement){
|
||||
if(typeof match === 'string'){
|
||||
return s.replace((new RegExp(goog.string.regExpEscape(match),"g")),replacement);
|
||||
} else {
|
||||
if((match instanceof RegExp)){
|
||||
if(typeof replacement === 'string'){
|
||||
return clojure.string.replace_all(s,match,replacement);
|
||||
} else {
|
||||
return clojure.string.replace_all(s,match,clojure.string.replace_with(replacement));
|
||||
}
|
||||
} else {
|
||||
throw ["Invalid match arg: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(match)].join('');
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Replaces the first instance of match with replacement in s.
|
||||
* match/replacement can be:
|
||||
*
|
||||
* string / string
|
||||
* pattern / (string or function of match).
|
||||
*/
|
||||
clojure.string.replace_first = (function clojure$string$replace_first(s,match,replacement){
|
||||
return s.replace(match,replacement);
|
||||
});
|
||||
/**
|
||||
* Returns a string of all elements in coll, as returned by (seq coll),
|
||||
* separated by an optional separator.
|
||||
*/
|
||||
clojure.string.join = (function clojure$string$join(var_args){
|
||||
var G__14500 = arguments.length;
|
||||
switch (G__14500) {
|
||||
case 1:
|
||||
return clojure.string.join.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return clojure.string.join.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.join.cljs$core$IFn$_invoke$arity$1 = (function (coll){
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var coll__$1 = cljs.core.seq(coll);
|
||||
while(true){
|
||||
if(!((coll__$1 == null))){
|
||||
var G__14502 = sb.append([cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first(coll__$1))].join(''));
|
||||
var G__14503 = cljs.core.next(coll__$1);
|
||||
sb = G__14502;
|
||||
coll__$1 = G__14503;
|
||||
continue;
|
||||
} else {
|
||||
return sb.toString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.join.cljs$core$IFn$_invoke$arity$2 = (function (separator,coll){
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var coll__$1 = cljs.core.seq(coll);
|
||||
while(true){
|
||||
if(!((coll__$1 == null))){
|
||||
sb.append([cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first(coll__$1))].join(''));
|
||||
|
||||
var coll__$2 = cljs.core.next(coll__$1);
|
||||
if((coll__$2 == null)){
|
||||
} else {
|
||||
sb.append(separator);
|
||||
}
|
||||
|
||||
var G__14504 = sb;
|
||||
var G__14505 = coll__$2;
|
||||
sb = G__14504;
|
||||
coll__$1 = G__14505;
|
||||
continue;
|
||||
} else {
|
||||
return sb.toString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.join.cljs$lang$maxFixedArity = 2;
|
||||
|
||||
/**
|
||||
* Converts string to all upper-case.
|
||||
*/
|
||||
clojure.string.upper_case = (function clojure$string$upper_case(s){
|
||||
return s.toUpperCase();
|
||||
});
|
||||
/**
|
||||
* Converts string to all lower-case.
|
||||
*/
|
||||
clojure.string.lower_case = (function clojure$string$lower_case(s){
|
||||
return s.toLowerCase();
|
||||
});
|
||||
/**
|
||||
* Converts first character of the string to upper-case, all other
|
||||
* characters to lower-case.
|
||||
*/
|
||||
clojure.string.capitalize = (function clojure$string$capitalize(s){
|
||||
return goog.string.capitalize(s);
|
||||
});
|
||||
clojure.string.pop_last_while_empty = (function clojure$string$pop_last_while_empty(v){
|
||||
var v__$1 = v;
|
||||
while(true){
|
||||
if(("" === cljs.core.peek(v__$1))){
|
||||
var G__14506 = cljs.core.pop(v__$1);
|
||||
v__$1 = G__14506;
|
||||
continue;
|
||||
} else {
|
||||
return v__$1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
clojure.string.discard_trailing_if_needed = (function clojure$string$discard_trailing_if_needed(limit,v){
|
||||
if((((0) === limit)) && (((1) < cljs.core.count(v)))){
|
||||
return clojure.string.pop_last_while_empty(v);
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
});
|
||||
clojure.string.split_with_empty_regex = (function clojure$string$split_with_empty_regex(s,limit){
|
||||
if(((limit <= (0))) || ((limit >= ((2) + cljs.core.count(s))))){
|
||||
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(cljs.core.vec(cljs.core.cons("",cljs.core.map.cljs$core$IFn$_invoke$arity$2(cljs.core.str,cljs.core.seq(s)))),"");
|
||||
} else {
|
||||
var pred__14507 = cljs.core._EQ__EQ_;
|
||||
var expr__14508 = limit;
|
||||
if(cljs.core.truth_((pred__14507.cljs$core$IFn$_invoke$arity$2 ? pred__14507.cljs$core$IFn$_invoke$arity$2((1),expr__14508) : pred__14507.call(null,(1),expr__14508)))){
|
||||
return (new cljs.core.PersistentVector(null,1,(5),cljs.core.PersistentVector.EMPTY_NODE,[s],null));
|
||||
} else {
|
||||
if(cljs.core.truth_((pred__14507.cljs$core$IFn$_invoke$arity$2 ? pred__14507.cljs$core$IFn$_invoke$arity$2((2),expr__14508) : pred__14507.call(null,(2),expr__14508)))){
|
||||
return (new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,["",s],null));
|
||||
} else {
|
||||
var c = (limit - (2));
|
||||
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(cljs.core.vec(cljs.core.cons("",cljs.core.subvec.cljs$core$IFn$_invoke$arity$3(cljs.core.vec(cljs.core.map.cljs$core$IFn$_invoke$arity$2(cljs.core.str,cljs.core.seq(s))),(0),c))),cljs.core.subs.cljs$core$IFn$_invoke$arity$2(s,c));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Splits string on a regular expression. Optional argument limit is
|
||||
* the maximum number of splits. Not lazy. Returns vector of the splits.
|
||||
*/
|
||||
clojure.string.split = (function clojure$string$split(var_args){
|
||||
var G__14511 = arguments.length;
|
||||
switch (G__14511) {
|
||||
case 2:
|
||||
return clojure.string.split.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.string.split.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.split.cljs$core$IFn$_invoke$arity$2 = (function (s,re){
|
||||
return clojure.string.split.cljs$core$IFn$_invoke$arity$3(s,re,(0));
|
||||
});
|
||||
|
||||
clojure.string.split.cljs$core$IFn$_invoke$arity$3 = (function (s,re,limit){
|
||||
return clojure.string.discard_trailing_if_needed(limit,((("/(?:)/" === [cljs.core.str.cljs$core$IFn$_invoke$arity$1(re)].join('')))?clojure.string.split_with_empty_regex(s,limit):(((limit < (1)))?cljs.core.vec([cljs.core.str.cljs$core$IFn$_invoke$arity$1(s)].join('').split(re)):(function (){var s__$1 = s;
|
||||
var limit__$1 = limit;
|
||||
var parts = cljs.core.PersistentVector.EMPTY;
|
||||
while(true){
|
||||
if(((1) === limit__$1)){
|
||||
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(parts,s__$1);
|
||||
} else {
|
||||
var m = cljs.core.re_find(re,s__$1);
|
||||
if(!((m == null))){
|
||||
var index = s__$1.indexOf(m);
|
||||
var G__14513 = s__$1.substring((index + cljs.core.count(m)));
|
||||
var G__14514 = (limit__$1 - (1));
|
||||
var G__14515 = cljs.core.conj.cljs$core$IFn$_invoke$arity$2(parts,s__$1.substring((0),index));
|
||||
s__$1 = G__14513;
|
||||
limit__$1 = G__14514;
|
||||
parts = G__14515;
|
||||
continue;
|
||||
} else {
|
||||
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(parts,s__$1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
})())));
|
||||
});
|
||||
|
||||
clojure.string.split.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* Splits s on
|
||||
* or
|
||||
* .
|
||||
*/
|
||||
clojure.string.split_lines = (function clojure$string$split_lines(s){
|
||||
return clojure.string.split.cljs$core$IFn$_invoke$arity$2(s,/\n|\r\n/);
|
||||
});
|
||||
/**
|
||||
* Removes whitespace from both ends of string.
|
||||
*/
|
||||
clojure.string.trim = (function clojure$string$trim(s){
|
||||
return goog.string.trim(s);
|
||||
});
|
||||
/**
|
||||
* Removes whitespace from the left side of string.
|
||||
*/
|
||||
clojure.string.triml = (function clojure$string$triml(s){
|
||||
return goog.string.trimLeft(s);
|
||||
});
|
||||
/**
|
||||
* Removes whitespace from the right side of string.
|
||||
*/
|
||||
clojure.string.trimr = (function clojure$string$trimr(s){
|
||||
return goog.string.trimRight(s);
|
||||
});
|
||||
/**
|
||||
* Removes all trailing newline \n or return \r characters from
|
||||
* string. Similar to Perl's chomp.
|
||||
*/
|
||||
clojure.string.trim_newline = (function clojure$string$trim_newline(s){
|
||||
var index = s.length;
|
||||
while(true){
|
||||
if((index === (0))){
|
||||
return "";
|
||||
} else {
|
||||
var ch = cljs.core.get.cljs$core$IFn$_invoke$arity$2(s,(index - (1)));
|
||||
if((("\n" === ch)) || (("\r" === ch))){
|
||||
var G__14516 = (index - (1));
|
||||
index = G__14516;
|
||||
continue;
|
||||
} else {
|
||||
return s.substring((0),index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* True is s is nil, empty, or contains only whitespace.
|
||||
*/
|
||||
clojure.string.blank_QMARK_ = (function clojure$string$blank_QMARK_(s){
|
||||
return goog.string.isEmptySafe(s);
|
||||
});
|
||||
/**
|
||||
* Return a new string, using cmap to escape each character ch
|
||||
* from s as follows:
|
||||
*
|
||||
* If (cmap ch) is nil, append ch to the new string.
|
||||
* If (cmap ch) is non-nil, append (str (cmap ch)) instead.
|
||||
*/
|
||||
clojure.string.escape = (function clojure$string$escape(s,cmap){
|
||||
var buffer = (new goog.string.StringBuffer());
|
||||
var length = s.length;
|
||||
var index = (0);
|
||||
while(true){
|
||||
if((length === index)){
|
||||
return buffer.toString();
|
||||
} else {
|
||||
var ch = s.charAt(index);
|
||||
var replacement = cljs.core.get.cljs$core$IFn$_invoke$arity$2(cmap,ch);
|
||||
if(!((replacement == null))){
|
||||
buffer.append([cljs.core.str.cljs$core$IFn$_invoke$arity$1(replacement)].join(''));
|
||||
} else {
|
||||
buffer.append(ch);
|
||||
}
|
||||
|
||||
var G__14517 = (index + (1));
|
||||
index = G__14517;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Return index of value (string or char) in s, optionally searching
|
||||
* forward from from-index or nil if not found.
|
||||
*/
|
||||
clojure.string.index_of = (function clojure$string$index_of(var_args){
|
||||
var G__14519 = arguments.length;
|
||||
switch (G__14519) {
|
||||
case 2:
|
||||
return clojure.string.index_of.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.string.index_of.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.index_of.cljs$core$IFn$_invoke$arity$2 = (function (s,value){
|
||||
var result = s.indexOf(value);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.index_of.cljs$core$IFn$_invoke$arity$3 = (function (s,value,from_index){
|
||||
var result = s.indexOf(value,from_index);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.index_of.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* Return last index of value (string or char) in s, optionally
|
||||
* searching backward from from-index or nil if not found.
|
||||
*/
|
||||
clojure.string.last_index_of = (function clojure$string$last_index_of(var_args){
|
||||
var G__14522 = arguments.length;
|
||||
switch (G__14522) {
|
||||
case 2:
|
||||
return clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$2 = (function (s,value){
|
||||
var result = s.lastIndexOf(value);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$3 = (function (s,value,from_index){
|
||||
var result = s.lastIndexOf(value,from_index);
|
||||
if((result < (0))){
|
||||
return null;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
clojure.string.last_index_of.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* True if s starts with substr.
|
||||
*/
|
||||
clojure.string.starts_with_QMARK_ = (function clojure$string$starts_with_QMARK_(s,substr){
|
||||
return goog.string.startsWith(s,substr);
|
||||
});
|
||||
/**
|
||||
* True if s ends with substr.
|
||||
*/
|
||||
clojure.string.ends_with_QMARK_ = (function clojure$string$ends_with_QMARK_(s,substr){
|
||||
return goog.string.endsWith(s,substr);
|
||||
});
|
||||
/**
|
||||
* True if s includes substr.
|
||||
*/
|
||||
clojure.string.includes_QMARK_ = (function clojure$string$includes_QMARK_(s,substr){
|
||||
return goog.string.contains(s,substr);
|
||||
});
|
||||
@@ -0,0 +1,96 @@
|
||||
; Copyright (c) Rich Hickey. All rights reserved.
|
||||
; The use and distribution terms for this software are covered by the
|
||||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
; By using this software in any fashion, you are agreeing to be bound by
|
||||
; the terms of this license.
|
||||
; You must not remove this notice, or any other, from this software.
|
||||
|
||||
;;; walk.cljs - generic tree walker with replacement
|
||||
|
||||
;; by Stuart Sierra
|
||||
;; Jul5 17, 2011
|
||||
|
||||
;; CHANGE LOG:
|
||||
;;
|
||||
;; * July 17, 2011: Port to ClojureScript
|
||||
;;
|
||||
;; * December 15, 2008: replaced 'walk' with 'prewalk' & 'postwalk'
|
||||
;;
|
||||
;; * December 9, 2008: first version
|
||||
|
||||
|
||||
(ns
|
||||
^{:author "Stuart Sierra",
|
||||
:doc "This file defines a generic tree walker for Clojure data
|
||||
structures. It takes any data structure (list, vector, map, set,
|
||||
seq), calls a function on every element, and uses the return value
|
||||
of the function in place of the original. This makes it fairly
|
||||
easy to write recursive search-and-replace functions, as shown in
|
||||
the examples.
|
||||
|
||||
Note: \"walk\" supports all Clojure data structures EXCEPT maps
|
||||
created with sorted-map-by. There is no (obvious) way to retrieve
|
||||
the sorting function."}
|
||||
clojure.walk)
|
||||
|
||||
(defn walk
|
||||
"Traverses form, an arbitrary data structure. inner and outer are
|
||||
functions. Applies inner to each element of form, building up a
|
||||
data structure of the same type, then applies outer to the result.
|
||||
Recognizes all Clojure data structures. Consumes seqs as with doall."
|
||||
|
||||
{:added "1.1"}
|
||||
[inner outer form]
|
||||
(cond
|
||||
(list? form) (outer (apply list (map inner form)))
|
||||
(seq? form) (outer (doall (map inner form)))
|
||||
(record? form) (outer (reduce (fn [r x] (conj r (inner x))) form form))
|
||||
(coll? form) (outer (into (empty form) (map inner form)))
|
||||
:else (outer form)))
|
||||
|
||||
(defn postwalk
|
||||
"Performs a depth-first, post-order traversal of form. Calls f on
|
||||
each sub-form, uses f's return value in place of the original.
|
||||
Recognizes all Clojure data structures. Consumes seqs as with doall."
|
||||
{:added "1.1"}
|
||||
[f form]
|
||||
(walk (partial postwalk f) f form))
|
||||
|
||||
(defn prewalk
|
||||
"Like postwalk, but does pre-order traversal."
|
||||
{:added "1.1"}
|
||||
[f form]
|
||||
(walk (partial prewalk f) identity (f form)))
|
||||
|
||||
(defn keywordize-keys
|
||||
"Recursively transforms all map keys from strings to keywords."
|
||||
{:added "1.1"}
|
||||
[m]
|
||||
(let [f (fn [[k v]] (if (string? k) [(keyword k) v] [k v]))]
|
||||
;; only apply to maps
|
||||
(postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))
|
||||
|
||||
(defn stringify-keys
|
||||
"Recursively transforms all map keys from keywords to strings."
|
||||
{:added "1.1"}
|
||||
[m]
|
||||
(let [f (fn [[k v]] (if (keyword? k) [(name k) v] [k v]))]
|
||||
;; only apply to maps
|
||||
(postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))
|
||||
|
||||
(defn prewalk-replace
|
||||
"Recursively transforms form by replacing keys in smap with their
|
||||
values. Like clojure/replace but works on any data structure. Does
|
||||
replacement at the root of the tree first."
|
||||
{:added "1.1"}
|
||||
[smap form]
|
||||
(prewalk (fn [x] (if (contains? smap x) (smap x) x)) form))
|
||||
|
||||
(defn postwalk-replace
|
||||
"Recursively transforms form by replacing keys in smap with their
|
||||
values. Like clojure/replace but works on any data structure. Does
|
||||
replacement at the leaves of the tree first."
|
||||
{:added "1.1"}
|
||||
[smap form]
|
||||
(postwalk (fn [x] (if (contains? smap x) (smap x) x)) form))
|
||||
@@ -0,0 +1,126 @@
|
||||
// Compiled by ClojureScript 1.9.946 {:static-fns true, :optimize-constants true}
|
||||
goog.provide('clojure.walk');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
/**
|
||||
* Traverses form, an arbitrary data structure. inner and outer are
|
||||
* functions. Applies inner to each element of form, building up a
|
||||
* data structure of the same type, then applies outer to the result.
|
||||
* Recognizes all Clojure data structures. Consumes seqs as with doall.
|
||||
*/
|
||||
clojure.walk.walk = (function clojure$walk$walk(inner,outer,form){
|
||||
if(cljs.core.list_QMARK_(form)){
|
||||
var G__14824 = cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.list,cljs.core.map.cljs$core$IFn$_invoke$arity$2(inner,form));
|
||||
return (outer.cljs$core$IFn$_invoke$arity$1 ? outer.cljs$core$IFn$_invoke$arity$1(G__14824) : outer.call(null,G__14824));
|
||||
} else {
|
||||
if(cljs.core.seq_QMARK_(form)){
|
||||
var G__14825 = cljs.core.doall.cljs$core$IFn$_invoke$arity$1(cljs.core.map.cljs$core$IFn$_invoke$arity$2(inner,form));
|
||||
return (outer.cljs$core$IFn$_invoke$arity$1 ? outer.cljs$core$IFn$_invoke$arity$1(G__14825) : outer.call(null,G__14825));
|
||||
} else {
|
||||
if(cljs.core.record_QMARK_(form)){
|
||||
var G__14826 = cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (r,x){
|
||||
return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(r,(inner.cljs$core$IFn$_invoke$arity$1 ? inner.cljs$core$IFn$_invoke$arity$1(x) : inner.call(null,x)));
|
||||
}),form,form);
|
||||
return (outer.cljs$core$IFn$_invoke$arity$1 ? outer.cljs$core$IFn$_invoke$arity$1(G__14826) : outer.call(null,G__14826));
|
||||
} else {
|
||||
if(cljs.core.coll_QMARK_(form)){
|
||||
var G__14827 = cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.empty(form),cljs.core.map.cljs$core$IFn$_invoke$arity$2(inner,form));
|
||||
return (outer.cljs$core$IFn$_invoke$arity$1 ? outer.cljs$core$IFn$_invoke$arity$1(G__14827) : outer.call(null,G__14827));
|
||||
} else {
|
||||
return (outer.cljs$core$IFn$_invoke$arity$1 ? outer.cljs$core$IFn$_invoke$arity$1(form) : outer.call(null,form));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Performs a depth-first, post-order traversal of form. Calls f on
|
||||
* each sub-form, uses f's return value in place of the original.
|
||||
* Recognizes all Clojure data structures. Consumes seqs as with doall.
|
||||
*/
|
||||
clojure.walk.postwalk = (function clojure$walk$postwalk(f,form){
|
||||
return clojure.walk.walk(cljs.core.partial.cljs$core$IFn$_invoke$arity$2(clojure.walk.postwalk,f),f,form);
|
||||
});
|
||||
/**
|
||||
* Like postwalk, but does pre-order traversal.
|
||||
*/
|
||||
clojure.walk.prewalk = (function clojure$walk$prewalk(f,form){
|
||||
return clojure.walk.walk(cljs.core.partial.cljs$core$IFn$_invoke$arity$2(clojure.walk.prewalk,f),cljs.core.identity,(f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(form) : f.call(null,form)));
|
||||
});
|
||||
/**
|
||||
* Recursively transforms all map keys from strings to keywords.
|
||||
*/
|
||||
clojure.walk.keywordize_keys = (function clojure$walk$keywordize_keys(m){
|
||||
var f = (function (p__14828){
|
||||
var vec__14829 = p__14828;
|
||||
var k = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14829,(0),null);
|
||||
var v = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14829,(1),null);
|
||||
if(typeof k === 'string'){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.keyword.cljs$core$IFn$_invoke$arity$1(k),v], null);
|
||||
} else {
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [k,v], null);
|
||||
}
|
||||
});
|
||||
return clojure.walk.postwalk(((function (f){
|
||||
return (function (x){
|
||||
if(cljs.core.map_QMARK_(x)){
|
||||
return cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.cljs$core$IFn$_invoke$arity$2(f,x));
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
});})(f))
|
||||
,m);
|
||||
});
|
||||
/**
|
||||
* Recursively transforms all map keys from keywords to strings.
|
||||
*/
|
||||
clojure.walk.stringify_keys = (function clojure$walk$stringify_keys(m){
|
||||
var f = (function (p__14832){
|
||||
var vec__14833 = p__14832;
|
||||
var k = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14833,(0),null);
|
||||
var v = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__14833,(1),null);
|
||||
if((k instanceof cljs.core.Keyword)){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.name(k),v], null);
|
||||
} else {
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [k,v], null);
|
||||
}
|
||||
});
|
||||
return clojure.walk.postwalk(((function (f){
|
||||
return (function (x){
|
||||
if(cljs.core.map_QMARK_(x)){
|
||||
return cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.cljs$core$IFn$_invoke$arity$2(f,x));
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
});})(f))
|
||||
,m);
|
||||
});
|
||||
/**
|
||||
* Recursively transforms form by replacing keys in smap with their
|
||||
* values. Like clojure/replace but works on any data structure. Does
|
||||
* replacement at the root of the tree first.
|
||||
*/
|
||||
clojure.walk.prewalk_replace = (function clojure$walk$prewalk_replace(smap,form){
|
||||
return clojure.walk.prewalk((function (x){
|
||||
if(cljs.core.contains_QMARK_(smap,x)){
|
||||
return (smap.cljs$core$IFn$_invoke$arity$1 ? smap.cljs$core$IFn$_invoke$arity$1(x) : smap.call(null,x));
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}),form);
|
||||
});
|
||||
/**
|
||||
* Recursively transforms form by replacing keys in smap with their
|
||||
* values. Like clojure/replace but works on any data structure. Does
|
||||
* replacement at the leaves of the tree first.
|
||||
*/
|
||||
clojure.walk.postwalk_replace = (function clojure$walk$postwalk_replace(smap,form){
|
||||
return clojure.walk.postwalk((function (x){
|
||||
if(cljs.core.contains_QMARK_(smap,x)){
|
||||
return (smap.cljs$core$IFn$_invoke$arity$1 ? smap.cljs$core$IFn$_invoke$arity$1(x) : smap.call(null,x));
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}),form);
|
||||
});
|
||||
Reference in new issue
Block a user