added github pages support
This commit is contained in:
1 parent
b14ebdbf63
commit
6ed638a1cc
373 files changed
+185436
-2343
No files matched your search
@@ -0,0 +1,162 @@
|
||||
; 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
|
||||
^{:author "Stuart Halloway",
|
||||
:doc "Non-core data functions."}
|
||||
clojure.data
|
||||
(:require [clojure.set :as set]))
|
||||
|
||||
(declare diff)
|
||||
|
||||
(defn- atom-diff
|
||||
"Internal helper for diff."
|
||||
[a b]
|
||||
(if (= a b) [nil nil a] [a b nil]))
|
||||
|
||||
;; for big things a sparse vector class would be better
|
||||
(defn- vectorize
|
||||
"Convert an associative-by-numeric-index collection into
|
||||
an equivalent vector, with nil for any missing keys"
|
||||
[m]
|
||||
(when (seq m)
|
||||
(reduce
|
||||
(fn [result [k v]] (assoc result k v))
|
||||
(vec (repeat (apply max (keys m)) nil))
|
||||
m)))
|
||||
|
||||
(defn- diff-associative-key
|
||||
"Diff associative things a and b, comparing only the key k."
|
||||
[a b k]
|
||||
(let [va (get a k)
|
||||
vb (get b k)
|
||||
[a* b* ab] (diff va vb)
|
||||
in-a (contains? a k)
|
||||
in-b (contains? b k)
|
||||
same (and in-a in-b
|
||||
(or (not (nil? ab))
|
||||
(and (nil? va) (nil? vb))))]
|
||||
[(when (and in-a (or (not (nil? a*)) (not same))) {k a*})
|
||||
(when (and in-b (or (not (nil? b*)) (not same))) {k b*})
|
||||
(when same {k ab})
|
||||
]))
|
||||
|
||||
(defn- diff-associative
|
||||
"Diff associative things a and b, comparing only keys in ks (if supplied)."
|
||||
([a b]
|
||||
(diff-associative a b (set/union (keys a) (keys b))))
|
||||
([a b ks]
|
||||
(reduce
|
||||
(fn [diff1 diff2]
|
||||
(doall (map merge diff1 diff2)))
|
||||
[nil nil nil]
|
||||
(map
|
||||
(partial diff-associative-key a b)
|
||||
ks))))
|
||||
|
||||
(defn- diff-sequential
|
||||
[a b]
|
||||
(vec (map vectorize (diff-associative
|
||||
(if (vector? a) a (vec a))
|
||||
(if (vector? b) b (vec b))
|
||||
(range (max (count a) (count b)))))))
|
||||
|
||||
(defn- diff-set
|
||||
[a b]
|
||||
[(not-empty (set/difference a b))
|
||||
(not-empty (set/difference b a))
|
||||
(not-empty (set/intersection a b))])
|
||||
|
||||
(defprotocol EqualityPartition
|
||||
"Implementation detail. Subject to change."
|
||||
(equality-partition [x] "Implementation detail. Subject to change."))
|
||||
|
||||
(defprotocol Diff
|
||||
"Implementation detail. Subject to change."
|
||||
(diff-similar [a b] "Implementation detail. Subject to change."))
|
||||
|
||||
(extend-protocol EqualityPartition
|
||||
nil
|
||||
(equality-partition [x] :atom)
|
||||
|
||||
string
|
||||
(equality-partition [x] :atom)
|
||||
|
||||
number
|
||||
(equality-partition [x] :atom)
|
||||
|
||||
array
|
||||
(equality-partition [x] :sequential)
|
||||
|
||||
function
|
||||
(equality-partition [x] :atom)
|
||||
|
||||
boolean
|
||||
(equality-partition [x] :atom)
|
||||
|
||||
default
|
||||
(equality-partition [x]
|
||||
(cond
|
||||
(satisfies? IMap x) :map
|
||||
(satisfies? ISet x) :set
|
||||
(satisfies? ISequential x) :sequential
|
||||
:default :atom)))
|
||||
|
||||
(extend-protocol Diff
|
||||
nil
|
||||
(diff-similar [a b]
|
||||
(atom-diff a b))
|
||||
|
||||
string
|
||||
(diff-similar [a b]
|
||||
(atom-diff a b))
|
||||
|
||||
number
|
||||
(diff-similar [a b]
|
||||
(atom-diff a b))
|
||||
|
||||
array
|
||||
(diff-similar [a b]
|
||||
(diff-sequential a b))
|
||||
|
||||
function
|
||||
(diff-similar [a b]
|
||||
(atom-diff a b))
|
||||
|
||||
boolean
|
||||
(diff-similar [a b]
|
||||
(atom-diff a b))
|
||||
|
||||
default
|
||||
(diff-similar [a b]
|
||||
((case (equality-partition a)
|
||||
:atom atom-diff
|
||||
:set diff-set
|
||||
:sequential diff-sequential
|
||||
:map diff-associative)
|
||||
a b)))
|
||||
|
||||
(defn diff
|
||||
"Recursively compares a and b, returning a tuple of
|
||||
[things-only-in-a things-only-in-b things-in-both].
|
||||
Comparison rules:
|
||||
|
||||
* For equal a and b, return [nil nil a].
|
||||
* Maps are subdiffed where keys match and values differ.
|
||||
* Sets are never subdiffed.
|
||||
* All sequential things are treated as associative collections
|
||||
by their indexes, with results returned as vectors.
|
||||
* Everything else (including strings!) is treated as
|
||||
an atom and compared for equality."
|
||||
[a b]
|
||||
(if (= a b)
|
||||
[nil nil a]
|
||||
(if (= (equality-partition a) (equality-partition b))
|
||||
(diff-similar a b)
|
||||
(atom-diff a b))))
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{:rename-macros {}, :renames {}, :externs {Error {}}, :use-macros {}, :excludes #{}, :name clojure.data, :imports nil, :requires {set clojure.set, clojure.set clojure.set}, :cljs.spec/speced-vars [], :uses nil, :defs {vectorize {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/data.cljs", :line 23, :column 8, :end-line 23, :end-column 17, :private true, :arglists (quote ([m])), :doc "Convert an associative-by-numeric-index collection into\n an equivalent vector, with nil for any missing keys"}, :private true, :name clojure.data/vectorize, :variadic false, :file "target/cljsbuild/public/js/out/clojure/data.cljs", :end-column 17, :method-params ([m]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 23, :end-line 23, :max-fixed-arity 1, :fn-var true, :arglists (quote ([m])), :doc "Convert an associative-by-numeric-index collection into\n an equivalent vector, with nil for any missing keys"}, diff {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/data.cljs", :line 144, :column 7, :end-line 144, :end-column 11, :arglists (quote ([a b])), :doc "Recursively compares a and b, returning a tuple of\n [things-only-in-a things-only-in-b things-in-both].\n Comparison rules:\n\n * For equal a and b, return [nil nil a].\n * Maps are subdiffed where keys match and values differ.\n * Sets are never subdiffed.\n * All sequential things are treated as associative collections\n by their indexes, with results returned as vectors.\n * Everything else (including strings!) is treated as\n an atom and compared for equality."}, :name clojure.data/diff, :variadic false, :file "target/cljsbuild/public/js/out/clojure/data.cljs", :end-column 11, :method-params ([a b]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 144, :end-line 144, :max-fixed-arity 2, :fn-var true, :arglists (quote ([a b])), :doc "Recursively compares a and b, returning a tuple of\n [things-only-in-a things-only-in-b things-in-both].\n Comparison rules:\n\n * For equal a and b, return [nil nil a].\n * Maps are subdiffed where keys match and values differ.\n * Sets are never subdiffed.\n * All sequential things are treated as associative collections\n by their indexes, with results returned as vectors.\n * Everything else (including strings!) is treated as\n an atom and compared for equality."}, atom-diff {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/data.cljs", :line 17, :column 8, :end-line 17, :end-column 17, :private true, :arglists (quote ([a b])), :doc "Internal helper for diff."}, :private true, :name clojure.data/atom-diff, :variadic false, :file "target/cljsbuild/public/js/out/clojure/data.cljs", :end-column 17, :method-params ([a b]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 17, :end-line 17, :max-fixed-arity 2, :fn-var true, :arglists (quote ([a b])), :doc "Internal helper for diff."}, diff-set {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/data.cljs", :line 69, :column 8, :end-line 69, :end-column 16, :private true, :arglists (quote ([a b]))}, :private true, :name clojure.data/diff-set, :variadic false, :file "target/cljsbuild/public/js/out/clojure/data.cljs", :end-column 16, :method-params ([a b]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 69, :end-line 69, :max-fixed-arity 2, :fn-var true, :arglists (quote ([a b]))}, equality-partition {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/data.cljs", :line 77, :column 4, :end-line 77, :end-column 22, :protocol clojure.data/EqualityPartition, :doc "Implementation detail. Subject to change.", :arglists (quote ([x]))}, :protocol clojure.data/EqualityPartition, :name clojure.data/equality-partition, :variadic false, :file "target/cljsbuild/public/js/out/clojure/data.cljs", :end-column 22, :method-params ([x]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 75, :end-line 77, :max-fixed-arity 1, :fn-var true, :arglists (quote ([x])), :doc "Implementation detail. Subject to change."}, EqualityPartition {:meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/data.cljs", :line 75, :column 14, :end-line 75, :end-column 31, :doc "Implementation detail. Subject to change.", :protocol-symbol true, :jsdoc ("@interface"), :protocol-info {:methods {equality-partition [[x]]}}}, :protocol-symbol true, :name clojure.data/EqualityPartition, :file "target/cljsbuild/public/js/out/clojure/data.cljs", :end-column 31, :column 1, :line 75, :protocol-info {:methods {equality-partition [[x]]}}, :info nil, :end-line 75, :tag any, :impls #{nil boolean number default array string function}, :doc "Implementation detail. Subject to change.", :jsdoc ("@interface")}, diff-associative {:protocol-inline nLine truncated
|
||||
@@ -0,0 +1,288 @@
|
||||
// Compiled by ClojureScript 1.9.946 {}
|
||||
goog.provide('clojure.data');
|
||||
goog.require('cljs.core');
|
||||
goog.require('clojure.set');
|
||||
/**
|
||||
* Internal helper for diff.
|
||||
*/
|
||||
clojure.data.atom_diff = (function clojure$data$atom_diff(a,b){
|
||||
if(cljs.core._EQ_.call(null,a,b)){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,null,a], null);
|
||||
} else {
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [a,b,null], null);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Convert an associative-by-numeric-index collection into
|
||||
* an equivalent vector, with nil for any missing keys
|
||||
*/
|
||||
clojure.data.vectorize = (function clojure$data$vectorize(m){
|
||||
if(cljs.core.seq.call(null,m)){
|
||||
return cljs.core.reduce.call(null,(function (result,p__40145){
|
||||
var vec__40146 = p__40145;
|
||||
var k = cljs.core.nth.call(null,vec__40146,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__40146,(1),null);
|
||||
return cljs.core.assoc.call(null,result,k,v);
|
||||
}),cljs.core.vec.call(null,cljs.core.repeat.call(null,cljs.core.apply.call(null,cljs.core.max,cljs.core.keys.call(null,m)),null)),m);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Diff associative things a and b, comparing only the key k.
|
||||
*/
|
||||
clojure.data.diff_associative_key = (function clojure$data$diff_associative_key(a,b,k){
|
||||
var va = cljs.core.get.call(null,a,k);
|
||||
var vb = cljs.core.get.call(null,b,k);
|
||||
var vec__40149 = clojure.data.diff.call(null,va,vb);
|
||||
var a_STAR_ = cljs.core.nth.call(null,vec__40149,(0),null);
|
||||
var b_STAR_ = cljs.core.nth.call(null,vec__40149,(1),null);
|
||||
var ab = cljs.core.nth.call(null,vec__40149,(2),null);
|
||||
var in_a = cljs.core.contains_QMARK_.call(null,a,k);
|
||||
var in_b = cljs.core.contains_QMARK_.call(null,b,k);
|
||||
var same = (in_a) && (in_b) && ((!((ab == null))) || (((va == null)) && ((vb == null))));
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [(((in_a) && ((!((a_STAR_ == null))) || (!(same))))?cljs.core.PersistentArrayMap.createAsIfByAssoc([k,a_STAR_]):null),(((in_b) && ((!((b_STAR_ == null))) || (!(same))))?cljs.core.PersistentArrayMap.createAsIfByAssoc([k,b_STAR_]):null),((same)?cljs.core.PersistentArrayMap.createAsIfByAssoc([k,ab]):null)], null);
|
||||
});
|
||||
/**
|
||||
* Diff associative things a and b, comparing only keys in ks (if supplied).
|
||||
*/
|
||||
clojure.data.diff_associative = (function clojure$data$diff_associative(var_args){
|
||||
var G__40153 = arguments.length;
|
||||
switch (G__40153) {
|
||||
case 2:
|
||||
return clojure.data.diff_associative.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return clojure.data.diff_associative.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.data.diff_associative.cljs$core$IFn$_invoke$arity$2 = (function (a,b){
|
||||
return clojure.data.diff_associative.call(null,a,b,clojure.set.union.call(null,cljs.core.keys.call(null,a),cljs.core.keys.call(null,b)));
|
||||
});
|
||||
|
||||
clojure.data.diff_associative.cljs$core$IFn$_invoke$arity$3 = (function (a,b,ks){
|
||||
return cljs.core.reduce.call(null,(function (diff1,diff2){
|
||||
return cljs.core.doall.call(null,cljs.core.map.call(null,cljs.core.merge,diff1,diff2));
|
||||
}),new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,null,null], null),cljs.core.map.call(null,cljs.core.partial.call(null,clojure.data.diff_associative_key,a,b),ks));
|
||||
});
|
||||
|
||||
clojure.data.diff_associative.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
clojure.data.diff_sequential = (function clojure$data$diff_sequential(a,b){
|
||||
return cljs.core.vec.call(null,cljs.core.map.call(null,clojure.data.vectorize,clojure.data.diff_associative.call(null,((cljs.core.vector_QMARK_.call(null,a))?a:cljs.core.vec.call(null,a)),((cljs.core.vector_QMARK_.call(null,b))?b:cljs.core.vec.call(null,b)),cljs.core.range.call(null,(function (){var x__35850__auto__ = cljs.core.count.call(null,a);
|
||||
var y__35851__auto__ = cljs.core.count.call(null,b);
|
||||
return ((x__35850__auto__ > y__35851__auto__) ? x__35850__auto__ : y__35851__auto__);
|
||||
})()))));
|
||||
});
|
||||
clojure.data.diff_set = (function clojure$data$diff_set(a,b){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.not_empty.call(null,clojure.set.difference.call(null,a,b)),cljs.core.not_empty.call(null,clojure.set.difference.call(null,b,a)),cljs.core.not_empty.call(null,clojure.set.intersection.call(null,a,b))], null);
|
||||
});
|
||||
|
||||
/**
|
||||
* Implementation detail. Subject to change.
|
||||
* @interface
|
||||
*/
|
||||
clojure.data.EqualityPartition = function(){};
|
||||
|
||||
/**
|
||||
* Implementation detail. Subject to change.
|
||||
*/
|
||||
clojure.data.equality_partition = (function clojure$data$equality_partition(x){
|
||||
if((!((x == null))) && (!((x.clojure$data$EqualityPartition$equality_partition$arity$1 == null)))){
|
||||
return x.clojure$data$EqualityPartition$equality_partition$arity$1(x);
|
||||
} else {
|
||||
var x__36231__auto__ = (((x == null))?null:x);
|
||||
var m__36232__auto__ = (clojure.data.equality_partition[goog.typeOf(x__36231__auto__)]);
|
||||
if(!((m__36232__auto__ == null))){
|
||||
return m__36232__auto__.call(null,x);
|
||||
} else {
|
||||
var m__36232__auto____$1 = (clojure.data.equality_partition["_"]);
|
||||
if(!((m__36232__auto____$1 == null))){
|
||||
return m__36232__auto____$1.call(null,x);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"EqualityPartition.equality-partition",x);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Implementation detail. Subject to change.
|
||||
* @interface
|
||||
*/
|
||||
clojure.data.Diff = function(){};
|
||||
|
||||
/**
|
||||
* Implementation detail. Subject to change.
|
||||
*/
|
||||
clojure.data.diff_similar = (function clojure$data$diff_similar(a,b){
|
||||
if((!((a == null))) && (!((a.clojure$data$Diff$diff_similar$arity$2 == null)))){
|
||||
return a.clojure$data$Diff$diff_similar$arity$2(a,b);
|
||||
} else {
|
||||
var x__36231__auto__ = (((a == null))?null:a);
|
||||
var m__36232__auto__ = (clojure.data.diff_similar[goog.typeOf(x__36231__auto__)]);
|
||||
if(!((m__36232__auto__ == null))){
|
||||
return m__36232__auto__.call(null,a,b);
|
||||
} else {
|
||||
var m__36232__auto____$1 = (clojure.data.diff_similar["_"]);
|
||||
if(!((m__36232__auto____$1 == null))){
|
||||
return m__36232__auto____$1.call(null,a,b);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Diff.diff-similar",a);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"null",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"null",(function (x){
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"string",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"string",(function (x){
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"number",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"number",(function (x){
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"array",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"array",(function (x){
|
||||
return new cljs.core.Keyword(null,"sequential","sequential",-1082983960);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"function",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"function",(function (x){
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"boolean",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"boolean",(function (x){
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.EqualityPartition,"_",true);
|
||||
|
||||
goog.object.set(clojure.data.equality_partition,"_",(function (x){
|
||||
if(((!((x == null)))?((((x.cljs$lang$protocol_mask$partition0$ & (1024))) || ((cljs.core.PROTOCOL_SENTINEL === x.cljs$core$IMap$)))?true:(((!x.cljs$lang$protocol_mask$partition0$))?cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IMap,x):false)):cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IMap,x))){
|
||||
return new cljs.core.Keyword(null,"map","map",1371690461);
|
||||
} else {
|
||||
if(((!((x == null)))?((((x.cljs$lang$protocol_mask$partition0$ & (4096))) || ((cljs.core.PROTOCOL_SENTINEL === x.cljs$core$ISet$)))?true:(((!x.cljs$lang$protocol_mask$partition0$))?cljs.core.native_satisfies_QMARK_.call(null,cljs.core.ISet,x):false)):cljs.core.native_satisfies_QMARK_.call(null,cljs.core.ISet,x))){
|
||||
return new cljs.core.Keyword(null,"set","set",304602554);
|
||||
} else {
|
||||
if(((!((x == null)))?((((x.cljs$lang$protocol_mask$partition0$ & (16777216))) || ((cljs.core.PROTOCOL_SENTINEL === x.cljs$core$ISequential$)))?true:(((!x.cljs$lang$protocol_mask$partition0$))?cljs.core.native_satisfies_QMARK_.call(null,cljs.core.ISequential,x):false)):cljs.core.native_satisfies_QMARK_.call(null,cljs.core.ISequential,x))){
|
||||
return new cljs.core.Keyword(null,"sequential","sequential",-1082983960);
|
||||
} else {
|
||||
return new cljs.core.Keyword(null,"atom","atom",-397043653);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
goog.object.set(clojure.data.Diff,"null",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"null",(function (a,b){
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"string",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"string",(function (a,b){
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"number",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"number",(function (a,b){
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"array",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"array",(function (a,b){
|
||||
return clojure.data.diff_sequential.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"function",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"function",(function (a,b){
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"boolean",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"boolean",(function (a,b){
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}));
|
||||
|
||||
goog.object.set(clojure.data.Diff,"_",true);
|
||||
|
||||
goog.object.set(clojure.data.diff_similar,"_",(function (a,b){
|
||||
return (function (){var G__40158 = clojure.data.equality_partition.call(null,a);
|
||||
var G__40158__$1 = (((G__40158 instanceof cljs.core.Keyword))?G__40158.fqn:null);
|
||||
switch (G__40158__$1) {
|
||||
case "atom":
|
||||
return clojure.data.atom_diff;
|
||||
|
||||
break;
|
||||
case "set":
|
||||
return clojure.data.diff_set;
|
||||
|
||||
break;
|
||||
case "sequential":
|
||||
return clojure.data.diff_sequential;
|
||||
|
||||
break;
|
||||
case "map":
|
||||
return clojure.data.diff_associative;
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__40158__$1)].join('')));
|
||||
|
||||
}
|
||||
})().call(null,a,b);
|
||||
}));
|
||||
/**
|
||||
* Recursively compares a and b, returning a tuple of
|
||||
* [things-only-in-a things-only-in-b things-in-both].
|
||||
* Comparison rules:
|
||||
*
|
||||
* * For equal a and b, return [nil nil a].
|
||||
* * Maps are subdiffed where keys match and values differ.
|
||||
* * Sets are never subdiffed.
|
||||
* * All sequential things are treated as associative collections
|
||||
* by their indexes, with results returned as vectors.
|
||||
* * Everything else (including strings!) is treated as
|
||||
* an atom and compared for equality.
|
||||
*/
|
||||
clojure.data.diff = (function clojure$data$diff(a,b){
|
||||
if(cljs.core._EQ_.call(null,a,b)){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,null,a], null);
|
||||
} else {
|
||||
if(cljs.core._EQ_.call(null,clojure.data.equality_partition.call(null,a),clojure.data.equality_partition.call(null,b))){
|
||||
return clojure.data.diff_similar.call(null,a,b);
|
||||
} else {
|
||||
return clojure.data.atom_diff.call(null,a,b);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data.js.map?rel=1517021943854
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/clojure\/data.js","sources":["data.cljs?rel=1517021943855"],"lineCount":288,"mappings":";AAQA;;;AAMA,AAAA,AAEA;;;yBAAA,zBAAOA,0DAEJC,EAAEC;AAFL,AAGE,GAAI,AAACC,yBAAEF,EAAEC;AAAT,0FAAA,KAAA,KAAqBD;;AAArB,8FAAA,JAAyBA,EAAEC;;;AAG7B;;;;yBAAA,zBAAOE,0DAGJC;AAHH,AAIE,GAAM,AAACC,wBAAID;AAAX,AACE,OAACE,2BACA,kBAAAC,PAAKG;AAAL,AAAA,IAAAF,aAAAD;QAAA,AAAAE,wBAAAD,WAAA,IAAA,3CAAaG;QAAb,AAAAF,wBAAAD,WAAA,IAAA,3CAAeI;AAAf,AAAmB,OAACC,0BAAMH,OAAOC,EAAEC;GACnC,AAACE,wBAAI,gGAAA,hGAACC,2BAAO,AAACC,0BAAMC,cAAI,AAACC,yBAAKd,WAC9BA;;AAJH;;;AAMF;;;oCAAA,pCAAOe,gFAEJnB,EAAEC,EAAEU;AAFP,AAGE,IAAMU,KAAG,AAACC,wBAAItB,EAAEW;IACVY,KAAG,AAACD,wBAAIrB,EAAEU;IADhBS,aAEiB,AAACO,4BAAKN,GAAGE;cAF1B,AAAAd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WAsBiBhE,EAAEC;AAtBnB,AAuBI,OAACF,iCAAUC,EAAEC;;;AAvBjB,AAAA,Line truncated
|
||||
@@ -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 @@
|
||||
{:rename-macros {}, :renames {}, :externs {Error {}}, :use-macros {}, :excludes #{}, :name clojure.set, :imports nil, :requires nil, :cljs.spec/speced-vars [], :uses nil, :defs {union {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/set.cljs", :line 19, :column 7, :end-line 19, :end-column 12, :arglists (quote ([] [s1] [s1 s2] [s1 s2 & sets])), :doc "Return a set that is the union of the input sets", :top-fn {:variadic true, :max-fixed-arity 2, :method-params ([] [s1] [s1 s2]), :arglists ([] [s1] [s1 s2] [s1 s2 & sets]), :arglists-meta (nil nil nil nil)}}, :name clojure.set/union, :variadic true, :file "target/cljsbuild/public/js/out/clojure/set.cljs", :end-column 12, :top-fn {:variadic true, :max-fixed-arity 2, :method-params ([] [s1] [s1 s2]), :arglists ([] [s1] [s1 s2] [s1 s2 & sets]), :arglists-meta (nil nil nil nil)}, :method-params ([] [s1] [s1 s2]), :protocol-impl nil, :arglists-meta (nil nil nil nil), :column 1, :line 19, :end-line 19, :max-fixed-arity 2, :fn-var true, :arglists ([] [s1] [s1 s2] [s1 s2 & sets]), :doc "Return a set that is the union of the input sets"}, map-invert {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/set.cljs", :line 97, :column 7, :end-line 97, :end-column 17, :arglists (quote ([m])), :doc "Returns the map with the vals mapped to the keys."}, :name clojure.set/map-invert, :variadic false, :file "target/cljsbuild/public/js/out/clojure/set.cljs", :end-column 17, :method-params ([m]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 97, :end-line 97, :max-fixed-arity 1, :fn-var true, :arglists (quote ([m])), :doc "Returns the map with the vals mapped to the keys."}, join {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/set.cljs", :line 101, :column 7, :end-line 101, :end-column 11, :arglists (quote ([xrel yrel] [xrel yrel km])), :doc "When passed 2 rels, returns the rel corresponding to the natural\n join. When passed an additional keymap, joins on the corresponding\n keys.", :top-fn {:variadic false, :max-fixed-arity 3, :method-params ([xrel yrel] [xrel yrel km]), :arglists ([xrel yrel] [xrel yrel km]), :arglists-meta (nil nil)}}, :name clojure.set/join, :variadic false, :file "target/cljsbuild/public/js/out/clojure/set.cljs", :end-column 11, :top-fn {:variadic false, :max-fixed-arity 3, :method-params ([xrel yrel] [xrel yrel km]), :arglists ([xrel yrel] [xrel yrel km]), :arglists-meta (nil nil)}, :method-params ([xrel yrel] [xrel yrel km]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 101, :end-line 101, :max-fixed-arity 3, :fn-var true, :arglists ([xrel yrel] [xrel yrel km]), :doc "When passed 2 rels, returns the rel corresponding to the natural\n join. When passed an additional keymap, joins on the corresponding\n keys."}, select {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/set.cljs", :line 61, :column 7, :end-line 61, :end-column 13, :arglists (quote ([pred xset])), :doc "Returns a set of the elements for which pred is true"}, :name clojure.set/select, :variadic false, :file "target/cljsbuild/public/js/out/clojure/set.cljs", :end-column 13, :method-params ([pred xset]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 61, :end-line 61, :max-fixed-arity 2, :fn-var true, :arglists (quote ([pred xset])), :doc "Returns a set of the elements for which pred is true"}, intersection {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/set.cljs", :line 31, :column 7, :end-line 31, :end-column 19, :arglists (quote ([s1] [s1 s2] [s1 s2 & sets])), :doc "Return a set that is the intersection of the input sets", :top-fn {:variadic true, :max-fixed-arity 2, :method-params ([s1] [s1 s2]), :arglists ([s1] [s1 s2] [s1 s2 & sets]), :arglists-meta (nil nil nil)}}, :name clojure.set/intersection, :variadic true, :file "target/cljsbuild/public/js/out/clojure/set.cljs", :end-column 19, :top-fn {:variadic true, :max-fixed-arity 2, :method-params ([s1] [s1 s2]), :arglists ([s1] [s1 s2] [s1 s2 & sets]), :arglists-meta (nil nil nil)}, :method-params ([s1] [s1 s2]), :protocol-impl nil, :arglists-meta (nil nil nil), :column 1, :line 31, :end-line 31, :max-fixed-arity 2, :fn-var true, :arglists ([s1] [s1 s2] [s1 s2 & sets]), :doc "Return a set that is the intersection of the input sets"}, superset? {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/set.cljs", :line 137, :column 7, :end-line 137, :end-column 16, :arglists (quote ([set1 set2])), :doc "Is set1 a superset of set2?"}, :name clojure.set/superset?, :variadic false, :file "target/cljsbuild/public/js/out/clojure/set.cljs", :end-column 16, :method-params ([set1 set2]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 137, :end-line Line truncated
|
||||
@@ -0,0 +1,385 @@
|
||||
// Compiled by ClojureScript 1.9.946 {}
|
||||
goog.provide('clojure.set');
|
||||
goog.require('cljs.core');
|
||||
clojure.set.bubble_max_key = (function clojure$set$bubble_max_key(k,coll){
|
||||
|
||||
var max = cljs.core.apply.call(null,cljs.core.max_key,k,coll);
|
||||
return cljs.core.cons.call(null,max,cljs.core.remove.call(null,((function (max){
|
||||
return (function (p1__37405_SHARP_){
|
||||
return (max === p1__37405_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__37410 = arguments.length;
|
||||
switch (G__37410) {
|
||||
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__36800__auto__ = [];
|
||||
var len__36777__auto___37412 = arguments.length;
|
||||
var i__36778__auto___37413 = (0);
|
||||
while(true){
|
||||
if((i__36778__auto___37413 < len__36777__auto___37412)){
|
||||
args_arr__36800__auto__.push((arguments[i__36778__auto___37413]));
|
||||
|
||||
var G__37414 = (i__36778__auto___37413 + (1));
|
||||
i__36778__auto___37413 = G__37414;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__36801__auto__ = (new cljs.core.IndexedSeq(args_arr__36800__auto__.slice((2)),(0),null));
|
||||
return clojure.set.union.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__36801__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.call(null,s1) < cljs.core.count.call(null,s2))){
|
||||
return cljs.core.reduce.call(null,cljs.core.conj,s2,s1);
|
||||
} else {
|
||||
return cljs.core.reduce.call(null,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.call(null,cljs.core.count,cljs.core.conj.call(null,sets,s2,s1));
|
||||
return cljs.core.reduce.call(null,cljs.core.into,cljs.core.first.call(null,bubbled_sets),cljs.core.rest.call(null,bubbled_sets));
|
||||
});
|
||||
|
||||
clojure.set.union.cljs$lang$applyTo = (function (seq37407){
|
||||
var G__37408 = cljs.core.first.call(null,seq37407);
|
||||
var seq37407__$1 = cljs.core.next.call(null,seq37407);
|
||||
var G__37409 = cljs.core.first.call(null,seq37407__$1);
|
||||
var seq37407__$2 = cljs.core.next.call(null,seq37407__$1);
|
||||
return clojure.set.union.cljs$core$IFn$_invoke$arity$variadic(G__37408,G__37409,seq37407__$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__37420 = arguments.length;
|
||||
switch (G__37420) {
|
||||
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__36800__auto__ = [];
|
||||
var len__36777__auto___37422 = arguments.length;
|
||||
var i__36778__auto___37423 = (0);
|
||||
while(true){
|
||||
if((i__36778__auto___37423 < len__36777__auto___37422)){
|
||||
args_arr__36800__auto__.push((arguments[i__36778__auto___37423]));
|
||||
|
||||
var G__37424 = (i__36778__auto___37423 + (1));
|
||||
i__36778__auto___37423 = G__37424;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__36801__auto__ = (new cljs.core.IndexedSeq(args_arr__36800__auto__.slice((2)),(0),null));
|
||||
return clojure.set.intersection.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__36801__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.call(null,s2) < cljs.core.count.call(null,s1))){
|
||||
var G__37425 = s2;
|
||||
var G__37426 = s1;
|
||||
s1 = G__37425;
|
||||
s2 = G__37426;
|
||||
continue;
|
||||
} else {
|
||||
return cljs.core.reduce.call(null,((function (s1,s2){
|
||||
return (function (result,item){
|
||||
if(cljs.core.contains_QMARK_.call(null,s2,item)){
|
||||
return result;
|
||||
} else {
|
||||
return cljs.core.disj.call(null,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.call(null,(function (p1__37415_SHARP_){
|
||||
return (- cljs.core.count.call(null,p1__37415_SHARP_));
|
||||
}),cljs.core.conj.call(null,sets,s2,s1));
|
||||
return cljs.core.reduce.call(null,clojure.set.intersection,cljs.core.first.call(null,bubbled_sets),cljs.core.rest.call(null,bubbled_sets));
|
||||
});
|
||||
|
||||
clojure.set.intersection.cljs$lang$applyTo = (function (seq37417){
|
||||
var G__37418 = cljs.core.first.call(null,seq37417);
|
||||
var seq37417__$1 = cljs.core.next.call(null,seq37417);
|
||||
var G__37419 = cljs.core.first.call(null,seq37417__$1);
|
||||
var seq37417__$2 = cljs.core.next.call(null,seq37417__$1);
|
||||
return clojure.set.intersection.cljs$core$IFn$_invoke$arity$variadic(G__37418,G__37419,seq37417__$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__37431 = arguments.length;
|
||||
switch (G__37431) {
|
||||
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__36800__auto__ = [];
|
||||
var len__36777__auto___37433 = arguments.length;
|
||||
var i__36778__auto___37434 = (0);
|
||||
while(true){
|
||||
if((i__36778__auto___37434 < len__36777__auto___37433)){
|
||||
args_arr__36800__auto__.push((arguments[i__36778__auto___37434]));
|
||||
|
||||
var G__37435 = (i__36778__auto___37434 + (1));
|
||||
i__36778__auto___37434 = G__37435;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__36801__auto__ = (new cljs.core.IndexedSeq(args_arr__36800__auto__.slice((2)),(0),null));
|
||||
return clojure.set.difference.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__36801__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.call(null,s1) < cljs.core.count.call(null,s2))){
|
||||
return cljs.core.reduce.call(null,(function (result,item){
|
||||
if(cljs.core.contains_QMARK_.call(null,s2,item)){
|
||||
return cljs.core.disj.call(null,result,item);
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}),s1,s1);
|
||||
} else {
|
||||
return cljs.core.reduce.call(null,cljs.core.disj,s1,s2);
|
||||
}
|
||||
});
|
||||
|
||||
clojure.set.difference.cljs$core$IFn$_invoke$arity$variadic = (function (s1,s2,sets){
|
||||
return cljs.core.reduce.call(null,clojure.set.difference,s1,cljs.core.conj.call(null,sets,s2));
|
||||
});
|
||||
|
||||
clojure.set.difference.cljs$lang$applyTo = (function (seq37428){
|
||||
var G__37429 = cljs.core.first.call(null,seq37428);
|
||||
var seq37428__$1 = cljs.core.next.call(null,seq37428);
|
||||
var G__37430 = cljs.core.first.call(null,seq37428__$1);
|
||||
var seq37428__$2 = cljs.core.next.call(null,seq37428__$1);
|
||||
return clojure.set.difference.cljs$core$IFn$_invoke$arity$variadic(G__37429,G__37430,seq37428__$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.call(null,(function (s,k){
|
||||
if(cljs.core.truth_(pred.call(null,k))){
|
||||
return s;
|
||||
} else {
|
||||
return cljs.core.disj.call(null,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.call(null,cljs.core.map.call(null,(function (p1__37436_SHARP_){
|
||||
return cljs.core.select_keys.call(null,p1__37436_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.call(null,(function (m,p__37437){
|
||||
var vec__37438 = p__37437;
|
||||
var old = cljs.core.nth.call(null,vec__37438,(0),null);
|
||||
var new$ = cljs.core.nth.call(null,vec__37438,(1),null);
|
||||
if(cljs.core.contains_QMARK_.call(null,map,old)){
|
||||
return cljs.core.assoc.call(null,m,new$,cljs.core.get.call(null,map,old));
|
||||
} else {
|
||||
return m;
|
||||
}
|
||||
}),cljs.core.apply.call(null,cljs.core.dissoc,map,cljs.core.keys.call(null,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.call(null,cljs.core.map.call(null,(function (p1__37441_SHARP_){
|
||||
return clojure.set.rename_keys.call(null,p1__37441_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.call(null,(function (m,x){
|
||||
var ik = cljs.core.select_keys.call(null,x,ks);
|
||||
return cljs.core.assoc.call(null,m,ik,cljs.core.conj.call(null,cljs.core.get.call(null,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.call(null,(function (m__$1,p__37442){
|
||||
var vec__37443 = p__37442;
|
||||
var k = cljs.core.nth.call(null,vec__37443,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__37443,(1),null);
|
||||
return cljs.core.assoc.call(null,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__37451 = arguments.length;
|
||||
switch (G__37451) {
|
||||
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.call(null,xrel)) && (cljs.core.seq.call(null,yrel))){
|
||||
var ks = clojure.set.intersection.call(null,cljs.core.set.call(null,cljs.core.keys.call(null,cljs.core.first.call(null,xrel))),cljs.core.set.call(null,cljs.core.keys.call(null,cljs.core.first.call(null,yrel))));
|
||||
var vec__37452 = (((cljs.core.count.call(null,xrel) <= cljs.core.count.call(null,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.call(null,vec__37452,(0),null);
|
||||
var s = cljs.core.nth.call(null,vec__37452,(1),null);
|
||||
var idx = clojure.set.index.call(null,r,ks);
|
||||
return cljs.core.reduce.call(null,((function (ks,vec__37452,r,s,idx){
|
||||
return (function (ret,x){
|
||||
var found = idx.call(null,cljs.core.select_keys.call(null,x,ks));
|
||||
if(cljs.core.truth_(found)){
|
||||
return cljs.core.reduce.call(null,((function (found,ks,vec__37452,r,s,idx){
|
||||
return (function (p1__37446_SHARP_,p2__37447_SHARP_){
|
||||
return cljs.core.conj.call(null,p1__37446_SHARP_,cljs.core.merge.call(null,p2__37447_SHARP_,x));
|
||||
});})(found,ks,vec__37452,r,s,idx))
|
||||
,ret,found);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
});})(ks,vec__37452,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__37455 = (((cljs.core.count.call(null,xrel) <= cljs.core.count.call(null,yrel)))?new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [xrel,yrel,clojure.set.map_invert.call(null,km)], null):new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [yrel,xrel,km], null));
|
||||
var r = cljs.core.nth.call(null,vec__37455,(0),null);
|
||||
var s = cljs.core.nth.call(null,vec__37455,(1),null);
|
||||
var k = cljs.core.nth.call(null,vec__37455,(2),null);
|
||||
var idx = clojure.set.index.call(null,r,cljs.core.vals.call(null,k));
|
||||
return cljs.core.reduce.call(null,((function (vec__37455,r,s,k,idx){
|
||||
return (function (ret,x){
|
||||
var found = idx.call(null,clojure.set.rename_keys.call(null,cljs.core.select_keys.call(null,x,cljs.core.keys.call(null,k)),k));
|
||||
if(cljs.core.truth_(found)){
|
||||
return cljs.core.reduce.call(null,((function (found,vec__37455,r,s,k,idx){
|
||||
return (function (p1__37448_SHARP_,p2__37449_SHARP_){
|
||||
return cljs.core.conj.call(null,p1__37448_SHARP_,cljs.core.merge.call(null,p2__37449_SHARP_,x));
|
||||
});})(found,vec__37455,r,s,k,idx))
|
||||
,ret,found);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
});})(vec__37455,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.call(null,set1) <= cljs.core.count.call(null,set2))) && (cljs.core.every_QMARK_.call(null,(function (p1__37459_SHARP_){
|
||||
return cljs.core.contains_QMARK_.call(null,set2,p1__37459_SHARP_);
|
||||
}),set1));
|
||||
});
|
||||
/**
|
||||
* Is set1 a superset of set2?
|
||||
*/
|
||||
clojure.set.superset_QMARK_ = (function clojure$set$superset_QMARK_(set1,set2){
|
||||
return ((cljs.core.count.call(null,set1) >= cljs.core.count.call(null,set2))) && (cljs.core.every_QMARK_.call(null,(function (p1__37460_SHARP_){
|
||||
return cljs.core.contains_QMARK_.call(null,set1,p1__37460_SHARP_);
|
||||
}),set2));
|
||||
});
|
||||
|
||||
//# sourceMappingURL=set.js.map?rel=1517021940738
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/clojure\/set.js","sources":["set.cljs?rel=1517021940740"],"lineCount":385,"mappings":";AAQA;;AAIA,6BAAA,7BAAOA,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AYiB,EAAErB;AAAxB,AACE,OAACc,0BAAMH,EAAEW,GAAG,AAAChD,yBAAK,6BAAA,7BAACyC,wBAAIJ,EAAEW,sCAAQD;GAHtC,mCAIItB;;AAER;;;yBAAA,zBAAMwB,0DAEHZ;AAFH,AAEM,OAACtC,2BAAO,iBAAAmD,NAAKb;AAAL,AAAA,IAAAc,aAAAD;QAAA,AAAAd,wBAAAe,WAAA,IAAA,3CAAQ5E;QAAR,AAAA6D,wBAAAe,WAAA,IAAA,3CAAUC;AAAV,AAAc,OAACZ,0BAAMH,MAAEe,EAAE7E;GAAjC,mCAAwC8D;;AAE9C,AAAA;;;;;mBAAA,2BAAAtD,9CAAMuE;AAAN,AAAA,IAAAD,WAAA,AAAA;AAAA,AAAA,QAAAA;KAAA;AAAA,OAAAC,+CAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;KAAA;AAAA,OAAAA,+CAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;;AAAA,MAAA,KAAAC,MAAA,CAAA,8DAAA,AAAA;;;;;AAAA,AAAA,iDAAA,jDAAMD,4DAIF7B,KAAK+B;AAJT,AAKG,GAAI,CAAK,AAACC,wBAAIhC,WAAM,AAACgC,wBAAID;AALine truncated
|
||||
@@ -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 @@
|
||||
{:rename-macros {}, :renames {}, :externs {RegExp {}, Error {}}, :use-macros {}, :excludes #{reverse replace}, :name clojure.string, :imports {StringBuffer goog.string.StringBuffer}, :requires {gstring goog.string, goog.string goog.string, StringBuffer goog.string.StringBuffer}, :cljs.spec/speced-vars [], :uses nil, :defs {ends-with? {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/string.cljs", :line 252, :column 16, :end-line 252, :end-column 26, :tag boolean, :arglists (quote ([s substr])), :doc "True if s ends with substr."}, :name clojure.string/ends-with?, :variadic false, :file "target/cljsbuild/public/js/out/clojure/string.cljs", :end-column 26, :method-params ([s substr]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 252, :ret-tag boolean, :end-line 252, :max-fixed-arity 2, :tag boolean, :fn-var true, :arglists (quote ([s substr])), :doc "True if s ends with substr."}, seq-reverse {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/string.cljs", :line 14, :column 8, :end-line 14, :end-column 19, :private true, :arglists (quote ([coll]))}, :private true, :name clojure.string/seq-reverse, :variadic false, :file "target/cljsbuild/public/js/out/clojure/string.cljs", :end-column 19, :method-params ([coll]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 14, :end-line 14, :max-fixed-arity 1, :fn-var true, :arglists (quote ([coll]))}, replace-with {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/string.cljs", :line 36, :column 8, :end-line 36, :end-column 20, :private true, :arglists (quote ([f]))}, :private true, :name clojure.string/replace-with, :variadic false, :file "target/cljsbuild/public/js/out/clojure/string.cljs", :end-column 20, :method-params ([f]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 36, :end-line 36, :max-fixed-arity 1, :fn-var true, :arglists (quote ([f]))}, capitalize {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/string.cljs", :line 100, :column 7, :end-line 100, :end-column 17, :arglists (quote ([s])), :doc "Converts first character of the string to upper-case, all other\n characters to lower-case."}, :name clojure.string/capitalize, :variadic false, :file "target/cljsbuild/public/js/out/clojure/string.cljs", :end-column 17, :method-params ([s]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 100, :end-line 100, :max-fixed-arity 1, :fn-var true, :arglists (quote ([s])), :doc "Converts first character of the string to upper-case, all other\n characters to lower-case."}, reverse {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/string.cljs", :line 21, :column 7, :end-line 21, :end-column 14, :arglists (quote ([s])), :doc "Returns s with its characters reversed."}, :name clojure.string/reverse, :variadic false, :file "target/cljsbuild/public/js/out/clojure/string.cljs", :end-column 14, :method-params ([s]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 21, :end-line 21, :max-fixed-arity 1, :fn-var true, :arglists (quote ([s])), :doc "Returns s with its characters reversed."}, join {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/string.cljs", :line 71, :column 7, :end-line 71, :end-column 11, :arglists (quote ([coll] [separator coll])), :doc "Returns a string of all elements in coll, as returned by (seq coll),\n separated by an optional separator.", :top-fn {:variadic false, :max-fixed-arity 2, :method-params ([coll] [separator coll]), :arglists ([coll] [separator coll]), :arglists-meta (nil nil)}}, :name clojure.string/join, :variadic false, :file "target/cljsbuild/public/js/out/clojure/string.cljs", :end-column 11, :top-fn {:variadic false, :max-fixed-arity 2, :method-params ([coll] [separator coll]), :arglists ([coll] [separator coll]), :arglists-meta (nil nil)}, :method-params ([coll] [separator coll]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 71, :end-line 71, :max-fixed-arity 2, :fn-var true, :arglists ([coll] [separator coll]), :doc "Returns a string of all elements in coll, as returned by (seq coll),\n separated by an optional separator."}, replace-first {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/string.cljs", :line 62, :column 7, :end-line 62, :end-column 20, :arglists (quote ([s match replacement])), :doc "Replaces the first instance of match with replacement in s.\n match/replacement can be:\n\n string / string\n pattern / (string or function of match)."}, :name clojure.string/replace-first, :variadic false, :file "target/cljsbuild/public/js/out/clojure/string.cljs", :end-column 20, :method-params ([s match replacement]), :protocol-impl nil, :argLine truncated
|
||||
@@ -0,0 +1,450 @@
|
||||
// Compiled by ClojureScript 1.9.946 {}
|
||||
goog.provide('clojure.string');
|
||||
goog.require('cljs.core');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
clojure.string.seq_reverse = (function clojure$string$seq_reverse(coll){
|
||||
return cljs.core.reduce.call(null,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__37355 = "g";
|
||||
var G__37355__$1 = (cljs.core.truth_(re.ignoreCase)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__37355),"i"].join(''):G__37355);
|
||||
var G__37355__$2 = (cljs.core.truth_(re.multiline)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__37355__$1),"m"].join(''):G__37355__$1);
|
||||
if(cljs.core.truth_(re.unicode)){
|
||||
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__37355__$2),"u"].join('');
|
||||
} else {
|
||||
return G__37355__$2;
|
||||
}
|
||||
})()));
|
||||
return s.replace(r,replacement);
|
||||
});
|
||||
clojure.string.replace_with = (function clojure$string$replace_with(f){
|
||||
return (function() {
|
||||
var G__37356__delegate = function (args){
|
||||
var matches = cljs.core.drop_last.call(null,(2),args);
|
||||
if(cljs.core._EQ_.call(null,cljs.core.count.call(null,matches),(1))){
|
||||
return f.call(null,cljs.core.first.call(null,matches));
|
||||
} else {
|
||||
return f.call(null,cljs.core.vec.call(null,matches));
|
||||
}
|
||||
};
|
||||
var G__37356 = function (var_args){
|
||||
var args = null;
|
||||
if (arguments.length > 0) {
|
||||
var G__37357__i = 0, G__37357__a = new Array(arguments.length - 0);
|
||||
while (G__37357__i < G__37357__a.length) {G__37357__a[G__37357__i] = arguments[G__37357__i + 0]; ++G__37357__i;}
|
||||
args = new cljs.core.IndexedSeq(G__37357__a,0,null);
|
||||
}
|
||||
return G__37356__delegate.call(this,args);};
|
||||
G__37356.cljs$lang$maxFixedArity = 0;
|
||||
G__37356.cljs$lang$applyTo = (function (arglist__37358){
|
||||
var args = cljs.core.seq(arglist__37358);
|
||||
return G__37356__delegate(args);
|
||||
});
|
||||
G__37356.cljs$core$IFn$_invoke$arity$variadic = G__37356__delegate;
|
||||
return G__37356;
|
||||
})()
|
||||
;
|
||||
});
|
||||
/**
|
||||
* 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.call(null,s,match,replacement);
|
||||
} else {
|
||||
return clojure.string.replace_all.call(null,s,match,clojure.string.replace_with.call(null,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__37360 = arguments.length;
|
||||
switch (G__37360) {
|
||||
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.call(null,coll);
|
||||
while(true){
|
||||
if(!((coll__$1 == null))){
|
||||
var G__37362 = sb.append([cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first.call(null,coll__$1))].join(''));
|
||||
var G__37363 = cljs.core.next.call(null,coll__$1);
|
||||
sb = G__37362;
|
||||
coll__$1 = G__37363;
|
||||
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.call(null,coll);
|
||||
while(true){
|
||||
if(!((coll__$1 == null))){
|
||||
sb.append([cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first.call(null,coll__$1))].join(''));
|
||||
|
||||
var coll__$2 = cljs.core.next.call(null,coll__$1);
|
||||
if((coll__$2 == null)){
|
||||
} else {
|
||||
sb.append(separator);
|
||||
}
|
||||
|
||||
var G__37364 = sb;
|
||||
var G__37365 = coll__$2;
|
||||
sb = G__37364;
|
||||
coll__$1 = G__37365;
|
||||
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.call(null,v__$1))){
|
||||
var G__37366 = cljs.core.pop.call(null,v__$1);
|
||||
v__$1 = G__37366;
|
||||
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.call(null,v)))){
|
||||
return clojure.string.pop_last_while_empty.call(null,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.call(null,s))))){
|
||||
return cljs.core.conj.call(null,cljs.core.vec.call(null,cljs.core.cons.call(null,"",cljs.core.map.call(null,cljs.core.str,cljs.core.seq.call(null,s)))),"");
|
||||
} else {
|
||||
var pred__37367 = cljs.core._EQ__EQ_;
|
||||
var expr__37368 = limit;
|
||||
if(cljs.core.truth_(pred__37367.call(null,(1),expr__37368))){
|
||||
return (new cljs.core.PersistentVector(null,1,(5),cljs.core.PersistentVector.EMPTY_NODE,[s],null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__37367.call(null,(2),expr__37368))){
|
||||
return (new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,["",s],null));
|
||||
} else {
|
||||
var c = (limit - (2));
|
||||
return cljs.core.conj.call(null,cljs.core.vec.call(null,cljs.core.cons.call(null,"",cljs.core.subvec.call(null,cljs.core.vec.call(null,cljs.core.map.call(null,cljs.core.str,cljs.core.seq.call(null,s))),(0),c))),cljs.core.subs.call(null,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__37371 = arguments.length;
|
||||
switch (G__37371) {
|
||||
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.call(null,s,re,(0));
|
||||
});
|
||||
|
||||
clojure.string.split.cljs$core$IFn$_invoke$arity$3 = (function (s,re,limit){
|
||||
return clojure.string.discard_trailing_if_needed.call(null,limit,((("/(?:)/" === [cljs.core.str.cljs$core$IFn$_invoke$arity$1(re)].join('')))?clojure.string.split_with_empty_regex.call(null,s,limit):(((limit < (1)))?cljs.core.vec.call(null,[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.call(null,parts,s__$1);
|
||||
} else {
|
||||
var m = cljs.core.re_find.call(null,re,s__$1);
|
||||
if(!((m == null))){
|
||||
var index = s__$1.indexOf(m);
|
||||
var G__37373 = s__$1.substring((index + cljs.core.count.call(null,m)));
|
||||
var G__37374 = (limit__$1 - (1));
|
||||
var G__37375 = cljs.core.conj.call(null,parts,s__$1.substring((0),index));
|
||||
s__$1 = G__37373;
|
||||
limit__$1 = G__37374;
|
||||
parts = G__37375;
|
||||
continue;
|
||||
} else {
|
||||
return cljs.core.conj.call(null,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.call(null,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.call(null,s,(index - (1)));
|
||||
if((("\n" === ch)) || (("\r" === ch))){
|
||||
var G__37376 = (index - (1));
|
||||
index = G__37376;
|
||||
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.call(null,cmap,ch);
|
||||
if(!((replacement == null))){
|
||||
buffer.append([cljs.core.str.cljs$core$IFn$_invoke$arity$1(replacement)].join(''));
|
||||
} else {
|
||||
buffer.append(ch);
|
||||
}
|
||||
|
||||
var G__37377 = (index + (1));
|
||||
index = G__37377;
|
||||
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__37379 = arguments.length;
|
||||
switch (G__37379) {
|
||||
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__37382 = arguments.length;
|
||||
switch (G__37382) {
|
||||
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);
|
||||
});
|
||||
|
||||
//# sourceMappingURL=string.js.map?rel=1517021940457
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/clojure\/string.js","sources":["string.cljs?rel=1517021940460"],"lineCount":450,"mappings":";AAQA;;;;AAKA,6BAAA,7BAAOA,kEACJC;AADH,AAEE,iDAAA,1CAACC,2BAAOC,oCAAQF;;AAElB,AAAeG,mCACb,KAAAC,OAAA,yCAAA;AAEF;;;yBAAA,zBAAMC,0DAEHC;AAFH,OAGM,2CAAA,3CAAUA,UAAEH,jBACZ,OAAA,AAAA,yDAAA,mBAAA;;AAEN,6BAAA,7BAAOI,kEACJD,EAAEE,GAAGC;AADR,AAEE,IAAMC,IAAE,KAAAN,OAAY,AAAUI,UACV,iBAAAG,WAAA;IAAAA,eAAA,sGAAAA,pFACE,AAAcH,eAAI,6CAAAG,UAAA;IADpBA,eAAA,yGAAAA,vFAEE,AAAaH,cAAI,6CAAAG,cAAA;AAFnB,AAAA,oBAGE,AAAWH;AAAI,oDAAAG,cAAA;;AAHjBA;;;AADpB,AAKE,OAAUL,UAAEI,EAAED;;AAElB,8BAAA,9BAAOG,oEACJC;AADH,AAEE;mCAAOC;AAAP,AACE,IAAMC,UAAQ,8BAAA,9BAACC,kCAAYF;AAA3B,AACE,GAAI,4DAAA,5DAACG,yBAAE,AAACC,0BAAMH;AACZ,OAACF,YAAE,AAACM,0BAAMJ;;AACV,OAACF,YAAE,AAACO,wBAAIL;;;;IAJPD;;;;EAAAA;;oCAAAA;;;IAAAA;0BAAAA;;;;;;;AAMT;;;;;;;yBAAA,zBAAMO,0DAMHf,EAAEgB,MAAMb;AANX,AAOE,GACE,OAASa;AACT,OAAUhB,UAAE,KAAAF,uCAAA,hCAAY,AAACmB,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;AAHH,AAIE,IAAOsD,QAAM,AAAUtD;;AAAvB,AACE,GAAI,WAAA,VAAOsD;AAAX;;AAEE,IAAMS,KAAG,AAACC,wBAAIhE,EAAE,SAAA,RAAKsD;AAArB,AACE,GAAI,CAAI,CAAA,SAAqBS,SACrB,CAAA,SAAoBA;AAC1B,eAAO,SAAA,RAAKT;;;;AACZ,mBAAA,ZAAYtD,gBAAIsD;;;;;;AAE1B;;;8BAAA,9BAAeW,oEAEZjE;AAFH,AAGE,OAACkE,wBAAoBlE;;AAEvB;;;;;;;wBAAA,xBAAMmE,wDAMHnE,EAAEoE;AANL,AAOE,IAAMC,SAAO,KAAA7C;IACP8C,SAAO,AAAUtE;AADvB,AAEE,YAAA,RAAOsD;;AAAP,AACE,GAAI,CAAIgB,WAAOhB;AACb,OAAGe;;AACH,IAAMN,KAAG,AAAS\/D,SAAEsD;IACdnD,cAAY,AAAC6D,wBAAII,KAAKL;AAD5B,AAEE,GAAA,EAAQ,gBAAA,fAAM5D;AACZ,AAASkE,cAAO,6CAAKlE;;AACrB,AAASkE,cAAON;;;AAClB,eAAO,SAAA,RAAKT;;;;;;;AAEtB,AAAA;;;;0BAAA,kCAAAnC,5DAAMqD;AAAN,AAAA,IAAAD,WAAA,AAAA;AAAA,AAAA,QAAAA;KAAA;AAAA,OAAAC,sDAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;KAAA;AAAA,OAAAA,sDAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;;AAAA,MAAA,KAAAlD,MAAA,CAAA,8DAAA,AAAA;;;;;AAAA,AAAA,wDAAA,xDAAMkD,mEAGFxE,EAAEyELine truncated
|
||||
@@ -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 @@
|
||||
{:rename-macros {}, :renames {}, :use-macros {}, :excludes #{}, :name clojure.walk, :imports nil, :requires nil, :cljs.spec/speced-vars [], :uses nil, :defs {walk {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/walk.cljs", :line 37, :column 7, :end-line 37, :end-column 11, :arglists (quote ([inner outer form])), :doc "Traverses form, an arbitrary data structure. inner and outer are\n functions. Applies inner to each element of form, building up a\n data structure of the same type, then applies outer to the result.\n Recognizes all Clojure data structures. Consumes seqs as with doall.", :added "1.1"}, :added "1.1", :name clojure.walk/walk, :variadic false, :file "target/cljsbuild/public/js/out/clojure/walk.cljs", :end-column 11, :method-params ([inner outer form]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 37, :end-line 37, :max-fixed-arity 3, :fn-var true, :arglists (quote ([inner outer form])), :doc "Traverses form, an arbitrary data structure. inner and outer are\n functions. Applies inner to each element of form, building up a\n data structure of the same type, then applies outer to the result.\n Recognizes all Clojure data structures. Consumes seqs as with doall."}, postwalk {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/walk.cljs", :line 52, :column 7, :end-line 52, :end-column 15, :arglists (quote ([f form])), :doc "Performs a depth-first, post-order traversal of form. Calls f on\n each sub-form, uses f's return value in place of the original.\n Recognizes all Clojure data structures. Consumes seqs as with doall.", :added "1.1"}, :added "1.1", :name clojure.walk/postwalk, :variadic false, :file "target/cljsbuild/public/js/out/clojure/walk.cljs", :end-column 15, :method-params ([f form]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 52, :end-line 52, :max-fixed-arity 2, :fn-var true, :arglists (quote ([f form])), :doc "Performs a depth-first, post-order traversal of form. Calls f on\n each sub-form, uses f's return value in place of the original.\n Recognizes all Clojure data structures. Consumes seqs as with doall."}, prewalk {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/walk.cljs", :line 60, :column 7, :end-line 60, :end-column 14, :arglists (quote ([f form])), :doc "Like postwalk, but does pre-order traversal.", :added "1.1"}, :added "1.1", :name clojure.walk/prewalk, :variadic false, :file "target/cljsbuild/public/js/out/clojure/walk.cljs", :end-column 14, :method-params ([f form]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 60, :end-line 60, :max-fixed-arity 2, :fn-var true, :arglists (quote ([f form])), :doc "Like postwalk, but does pre-order traversal."}, keywordize-keys {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/walk.cljs", :line 66, :column 7, :end-line 66, :end-column 22, :arglists (quote ([m])), :doc "Recursively transforms all map keys from strings to keywords.", :added "1.1"}, :added "1.1", :name clojure.walk/keywordize-keys, :variadic false, :file "target/cljsbuild/public/js/out/clojure/walk.cljs", :end-column 22, :method-params ([m]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 66, :end-line 66, :max-fixed-arity 1, :fn-var true, :arglists (quote ([m])), :doc "Recursively transforms all map keys from strings to keywords."}, stringify-keys {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/walk.cljs", :line 74, :column 7, :end-line 74, :end-column 21, :arglists (quote ([m])), :doc "Recursively transforms all map keys from keywords to strings.", :added "1.1"}, :added "1.1", :name clojure.walk/stringify-keys, :variadic false, :file "target/cljsbuild/public/js/out/clojure/walk.cljs", :end-column 21, :method-params ([m]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 74, :end-line 74, :max-fixed-arity 1, :fn-var true, :arglists (quote ([m])), :doc "Recursively transforms all map keys from keywords to strings."}, prewalk-replace {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/clojure/walk.cljs", :line 82, :column 7, :end-line 82, :end-column 22, :arglists (quote ([smap form])), :doc "Recursively transforms form by replacing keys in smap with their\n values. Like clojure/replace but works on any data structure. Does\n replacement at the root of the tree first.", :added "1.1"}, :added "1.1", :name clojure.walk/prewalk-replace, :variadic false, :file "target/cljsbuild/public/js/out/clojure/walk.cljs", :end-column 22, :method-params ([smap form]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 82, :end-line 82, :max-fixed-arity 2, :fn-var true, :arglists (quote ([smap form])), :doc "Recursively transforms form by replaLine truncated
|
||||
@@ -0,0 +1,123 @@
|
||||
// Compiled by ClojureScript 1.9.946 {}
|
||||
goog.provide('clojure.walk');
|
||||
goog.require('cljs.core');
|
||||
/**
|
||||
* 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_.call(null,form)){
|
||||
return outer.call(null,cljs.core.apply.call(null,cljs.core.list,cljs.core.map.call(null,inner,form)));
|
||||
} else {
|
||||
if(cljs.core.seq_QMARK_.call(null,form)){
|
||||
return outer.call(null,cljs.core.doall.call(null,cljs.core.map.call(null,inner,form)));
|
||||
} else {
|
||||
if(cljs.core.record_QMARK_.call(null,form)){
|
||||
return outer.call(null,cljs.core.reduce.call(null,(function (r,x){
|
||||
return cljs.core.conj.call(null,r,inner.call(null,x));
|
||||
}),form,form));
|
||||
} else {
|
||||
if(cljs.core.coll_QMARK_.call(null,form)){
|
||||
return outer.call(null,cljs.core.into.call(null,cljs.core.empty.call(null,form),cljs.core.map.call(null,inner,form)));
|
||||
} else {
|
||||
return 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.call(null,cljs.core.partial.call(null,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.call(null,cljs.core.partial.call(null,clojure.walk.prewalk,f),cljs.core.identity,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__37657){
|
||||
var vec__37658 = p__37657;
|
||||
var k = cljs.core.nth.call(null,vec__37658,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__37658,(1),null);
|
||||
if(typeof k === 'string'){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.keyword.call(null,k),v], null);
|
||||
} else {
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [k,v], null);
|
||||
}
|
||||
});
|
||||
return clojure.walk.postwalk.call(null,((function (f){
|
||||
return (function (x){
|
||||
if(cljs.core.map_QMARK_.call(null,x)){
|
||||
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,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__37661){
|
||||
var vec__37662 = p__37661;
|
||||
var k = cljs.core.nth.call(null,vec__37662,(0),null);
|
||||
var v = cljs.core.nth.call(null,vec__37662,(1),null);
|
||||
if((k instanceof cljs.core.Keyword)){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.name.call(null,k),v], null);
|
||||
} else {
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [k,v], null);
|
||||
}
|
||||
});
|
||||
return clojure.walk.postwalk.call(null,((function (f){
|
||||
return (function (x){
|
||||
if(cljs.core.map_QMARK_.call(null,x)){
|
||||
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,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.call(null,(function (x){
|
||||
if(cljs.core.contains_QMARK_.call(null,smap,x)){
|
||||
return 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.call(null,(function (x){
|
||||
if(cljs.core.contains_QMARK_.call(null,smap,x)){
|
||||
return smap.call(null,x);
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}),form);
|
||||
});
|
||||
|
||||
//# sourceMappingURL=walk.js.map?rel=1517021941127
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/clojure\/walk.js","sources":["walk.cljs?rel=1517021941127"],"lineCount":123,"mappings":";AAsBA;;AAcA;;;;;;oBAAA,pBAAMA,gDAOHC,MAAMC,MAAMC;AAPf,AAQE,GACE,AAACC,gCAAMD;AAAQ,OAACD,gBAAM,AAACG,0BAAMC,eAAK,AAACC,wBAAIN,MAAME;;AAD\/C,GAEE,AAACK,+BAAKL;AAAS,OAACD,gBAAM,AAACO,0BAAM,AAACF,wBAAIN,MAAME;;AAF1C,GAGE,AAACO,kCAAQP;AAAM,OAACD,gBAAM,AAACS,2BAAO,WAAKC,EAAEC;AAAP,AAAU,OAACC,yBAAKF,EAAE,AAACX,gBAAMY;GAAKV,KAAKA;;AAHnE,GAIE,AAACY,gCAAMZ;AAAQ,OAACD,gBAAM,AAACc,yBAAK,AAACC,0BAAMd,MAAM,AAACI,wBAAIN,MAAME;;AAJtD,AAKiB,OAACD,gBAAMC;;;;;;;AAE1B;;;;;wBAAA,xBAAMe,wDAKHC,EAAEhB;AALL,AAME,OAACH,4BAAK,AAACoB,4BAAQF,sBAAS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UD,KAAKzB;AAAG,OAACyB,eAAKzB;;AAAGA;;GAAIV","names":["clojure.walk\/walk","inner","outer","form","cljs.core\/list?","cljs.core\/apply","cljs.core\/list","cljs.core\/map","cljs.core\/seq?","cljs.core\/doall","cljs.core\/record?","cljs.core\/reduce","r","x","cljs.core\/conj","cljs.core\/coll?","cljs.core\/into","cljs.core\/empty","clojure.walk\/postwalk","f","cljs.core\/partial","clojure.walk\/prewalk","cljs.core\/identity","clojure.walk\/keywordize-keys","m","p__37657","vec__37658","cljs.core\/nth","k","v","cljs.core\/keyword","cljs.core\/map?","clojure.walk\/stringify-keys","p__37661","vec__37662","cljs.core\/Keyword","cljs.core\/name","clojure.walk\/prewalk-replace","smap","cljs.core\/contains?","clojure.walk\/postwalk-replace"]}
|
||||
Reference in new issue
Block a user