Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 4 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Showing with 28 additions and 6 deletions.
  1. +17 −4 README.md
  2. +11 −2 src/mori.cljs
View
21 README.md
@@ -51,9 +51,9 @@ Note: If you are using leiningen 2, use this for your project.clj
{:source-paths
["comp/clojurescript/src/clj"
"comp/clojurescript/src/cljs"]}}
- :cljsbuild {:builds {:release {:source-path "src"
- :compiler {:optimizations :advanced
- :output-to "mori.js"}}}})
+ :cljsbuild {:builds {:tmp {:source-path "src"
+ :compiler {:optimizations :advanced
+ :output-to "tmp.js"}}}})
```
Usage
@@ -134,7 +134,7 @@ time(function() {
a.map(mul3).filter(mori.is_even).map(mori.inc).reduce(mori.sum);
})
-// this already impressive given the level of abstraction
+// impressive given the level of abstraction
// expect us to get more competitive :D
```
@@ -181,6 +181,19 @@ second(mori.vector(1,2,3));
// => 2
```
+Juxtaposition
+-------------
+
+```javascript
+var pos_and_neg = mori.juxt(mori.identity, function (v) { return -v; });
+pos_and_neg(1);
+// => [1 -1]
+
+mori.knit(mori.inc, mori.dec)(pos_and_neg(1));
+// => [2 -2]
+```
+
+
Copyright (C) 2012 David Nolen and contributors
Distributed under the Eclipse Public License, the same as Clojure.
View
13 src/mori.cljs
@@ -9,7 +9,8 @@
map mapcat reduce reduce-kv filter remove some every? equiv
range repeat repeatedly sort sort-by
into-array
- partial comp
+ partial comp juxt
+ identity constantly
list vector hash-map set sorted-set
sum inc dec even? odd?])
(:require [clojure.set :as set]
@@ -100,6 +101,11 @@
(fn [arg]
(apply fun (cons arg args))))
+(def ^:export juxt cljs.core/juxt)
+(defn ^:export knit [& fns]
+ (fn [args]
+ (vec (map #(% %2) fns args))))
+
;; Useful fns
(def ^:export sum (fn [s n] (+ s n)))
@@ -110,4 +116,7 @@
(defn ^:export each [xs f]
(doseq [x (seq xs)]
- (f x)))
+ (f x)))
+
+(def ^:export identity cljs.core/identity)
+(def ^:export constantly cljs.core/constantly)

No commit comments for this range

Something went wrong with that request. Please try again.