├── .gitmodules ├── .gitignore ├── .travis.yml ├── project.clj ├── README.md ├── src ├── test │ └── multiset │ │ └── t_core.clj └── main │ └── multiset │ └── core.clj └── COPYING /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "doc"] 2 | path = doc 3 | url = git@github.com:achim/multiset.git 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | *.jar 7 | *.class 8 | .lein-deps-sum 9 | .lein-failures 10 | .lein-plugins 11 | *.sublime-project 12 | *.sublime-workspace 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: clojure 2 | lein: lein2 3 | script: lein2 midje 4 | jdk: 5 | - oraclejdk7 6 | - oraclejdk8 7 | - openjdk7 8 | after_success: 9 | - lein2 deploy clojars-https 10 | env: 11 | global: 12 | secure: PNQmjUOSzxPy4mEzGsSVKYiZxF/yeN4TwS84U7jZNgsnOYCnjmgW5lyEYZ6a4mnl8RH7v/RiDLqLV3Wa4pcWvdRdJSSx14SDZCu3jCkGEhgVmuyUOQvfn6qNVHqdyOvzB2Z11srENURfULK+L8bqXhqFFpbJKNDbUTo2q/goz/E= 13 | git: 14 | submodules: false -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject org.clojars.achim/multiset "0.1.1-SNAPSHOT" 2 | 3 | :description "A simple multiset/bag implementation for Clojure." 4 | :url "https://github.com/achim/multiset" 5 | :license {:name "Eclipse Public License" 6 | :url "http://www.eclipse.org/legal/epl-v10.html"} 7 | 8 | :repositories {"clojars-https" {:url "https://clojars.org/repo" 9 | :username "achim" 10 | :password :env}} 11 | 12 | :source-paths ["src" "src/main"] 13 | :test-paths ["test" "src/test"] 14 | 15 | :dependencies [[org.clojure/clojure "1.10.1"] 16 | [org.clojure/algo.generic "0.1.3"]] 17 | 18 | :profiles {:dev {:dependencies [[midje "1.9.9"]] 19 | :plugins [[lein-html5-docs "3.0.1"] 20 | [lein-midje "3.1.3"]] 21 | :html5-docs-docs-dir "doc" 22 | :html5-docs-ns-includes #"multiset\..*" 23 | :html5-docs-ns-excludes #".*\.t_.*" 24 | :html5-docs-repository-url ""}}) 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # multiset [![Build Status](https://travis-ci.org/achim/multiset.svg)](https://travis-ci.org/achim/multiset) 2 | 3 | A simple multiset/bag implementation for Clojure. 4 | 5 | ## Usage 6 | 7 | ### Installation via Leiningen 8 | 9 | Add this to your `:depependencies`: 10 | 11 | ![Clojars Project](http://clojars.org/org.clojars.achim/multiset/latest-version.svg) 12 | 13 | ### [API Docs](http://achim.github.com/multiset/) 14 | 15 | The current API docs are here: http://achim.github.io/multiset 16 | 17 | ### Example usage 18 | 19 | #### Define some multisets 20 | ```clojure 21 | user=> (require '[multiset.core :as ms]) 22 | nil 23 | user=> (def a (ms/multiset 1 2 4 5 4 2 7)) 24 | #'user/a 25 | user=> (def b (ms/multiset 4 5 6 6 9)) 26 | #'user/b 27 | user=> (def c (ms/multiset 1 2 4 7)) 28 | #'user/c 29 | ``` 30 | #### Basic functionality 31 | ```clojure 32 | user=> a 33 | #{7 5 4 4 2 2 1} 34 | user=> (contains? a 3) 35 | false 36 | user=> (contains? a 2) 37 | true 38 | user=> (disj a 2) 39 | #{7 5 4 4 2 1} 40 | user=> (conj a 4) 41 | #{7 5 4 4 4 2 2 1} 42 | user=> (a 2) 43 | ``` 44 | #### Multiset-specific stuff 45 | ```clojure 46 | user=> (ms/multiset? a) 47 | true 48 | user=> (ms/multiplicities a) 49 | {7 1, 5 1, 4 2, 2 2, 1 1} 50 | user=> (ms/multiplicity a 3) 51 | 0 52 | user=> (ms/multiplicity a 2) 53 | 2 54 | ``` 55 | #### Multiset operators 56 | ```clojure 57 | user=> (ms/intersect a (conj b 4)) 58 | #{5 4 4} 59 | user=> (ms/union a b) 60 | #{1 2 2 4 4 5 6 6 7 9} 61 | user=> (ms/sum a b) 62 | #{1 2 2 4 4 4 5 5 6 6 7 9} 63 | user=> (ms/minus a b) 64 | #{7 4 2 2 1} 65 | user=> (ms/scale a 3) 66 | #{7 7 7 5 5 5 4 4 4 4 4 4 2 2 2 2 2 2 1 1 1} 67 | user=> (ms/cartprod a b) 68 | #{[5 4] [7 6] [7 6] [4 4] [4 4] [5 5] [4 5] [4 5] [5 6] [5 6] [2 4] [2 4] [4 6] [4 6] [4 6] [4 6] [7 9] [2 5] [2 5] [1 4] [2 6] [2 6] [2 6] [2 6] [5 9] [1 5] [4 9] [4 9] [1 6] [1 6] [2 9] [2 9] [1 9] [7 4] [7 5]} 69 | user=> (ms/subset? a b) 70 | false 71 | user=> (ms/subset? c a) 72 | true 73 | user=> (ms/subset? (ms/multiset 2 2 2) a) 74 | false 75 | ``` 76 | 77 | ## License 78 | 79 | Copyright (C) 2012–2015 Achim Passen and [contributors](https://github.com/achim/multiset/graphs/contributors). 80 | 81 | Distributed under the Eclipse Public License. See COPYING. 82 | -------------------------------------------------------------------------------- /src/test/multiset/t_core.clj: -------------------------------------------------------------------------------- 1 | (ns multiset.t_core 2 | (:require [multiset.core :as ms] 3 | [midje.sweet :refer :all]) 4 | (:import [multiset.core MultiSet])) 5 | 6 | 7 | (fact "get/invoke works like partial identity" 8 | (let [x1 (Object.) 9 | x2 (Object.) 10 | a (ms/multiset x1 x2 4 5 4 x2 7)] 11 | (get a x1) => x1 12 | (get a x2) => x2 13 | (get a 23) => nil 14 | (a x1) => x1 15 | (a x2) => x2 16 | (a 23) => nil)) 17 | 18 | (let [a (ms/multiset 1 2 4 5 4 2 7)] 19 | (fact "contains works correctly" 20 | (contains? a 0) => falsey 21 | (contains? a 2) => truthy 22 | (contains? a 7) => truthy) 23 | 24 | (fact "disj works correctly" 25 | (contains? (disj a 7) 7) => falsey 26 | (contains? (disj a 2) 2) => truthy 27 | (contains? (-> a (disj 2) (disj 2)) 2) => falsey)) 28 | 29 | (fact "conj works correctly" 30 | (let [e (ms/multiset)] 31 | (contains? (conj e 1) 1) => truthy 32 | (contains? (-> e (conj 1) (conj 1)) 1) => truthy 33 | (contains? (-> e (conj 1) (conj 1)) (disj 1)) => truthy 34 | (contains? e 1) => falsey)) 35 | 36 | (fact "count works correctly" 37 | (count (ms/multiset)) => 0 38 | (count (ms/multiset 1)) => 1 39 | (count (ms/multiset 1 2 1)) => 3) 40 | 41 | (fact "value-based equality" 42 | (let [a (ms/multiset 1 2 2 4 7) 43 | b (ms/multiset 4 2 2 7 1)] 44 | (= a b) => truthy)) 45 | 46 | (fact "seq retains falsey values" 47 | (let [a (ms/multiset nil nil false false)] 48 | (apply ms/multiset (seq a)) => a)) 49 | 50 | (fact "empty multiset is a multiset" 51 | (instance? MultiSet (empty (ms/multiset)))) 52 | 53 | (fact "multiplicites are counted correctly" 54 | (let [a (ms/multiset 2 1 3 2 3 3)] 55 | (ms/multiplicities a) => {1 1 2 2 3 3})) 56 | 57 | (fact "multiplicities are returned correctly" 58 | (let [a (ms/multiset 4 4 4 4 5)] 59 | (ms/multiplicity a 4) => 4 60 | (ms/multiplicity a 7) => 0)) 61 | 62 | (let [a (ms/multiset 1 2 4 5 4 2 7) 63 | b (ms/multiset 4 5 6 6 9)] 64 | 65 | (fact "intersections work" 66 | (ms/intersect a (conj b 4)) => (ms/multiset 5 4 4)) 67 | 68 | (fact "unions work" 69 | (ms/union a b) => (ms/multiset 1 2 2 4 4 5 6 6 7 9)) 70 | 71 | (fact "sums work" 72 | (ms/sum a b) => (ms/multiset 1 2 2 4 4 4 5 5 6 6 7 9)) 73 | 74 | (fact "minuses work" 75 | (ms/minus a b) => (ms/multiset 7 4 2 2 1)) 76 | 77 | (fact "scaling multiplicites" 78 | (ms/scale a 3) => (ms/multiset 7 7 7 5 5 5 4 4 4 4 4 4 2 2 2 2 2 2 1 1 1) 79 | (ms/scale a 0) => (ms/multiset) 80 | (ms/scale a -1) => nil) 81 | 82 | (fact "we can do cartesian products" 83 | (ms/cartprod a b) => (ms/multiset 84 | [5 4] [7 6] [7 6] [4 4] [4 4] [5 5] [4 5] [4 5] 85 | [5 6] [5 6] [2 4] [2 4] [4 6] [4 6] [4 6] [4 6] 86 | [7 9] [2 5] [2 5] [1 4] [2 6] [2 6] [2 6] [2 6] 87 | [5 9] [1 5] [4 9] [4 9] [1 6] [1 6] [2 9] [2 9] 88 | [1 9] [7 4] [7 5]))) 89 | 90 | (fact "subset? is correct" 91 | (ms/subset? (ms/multiset 1 2 3) (ms/multiset 1 2 2 3 3 4)) => truthy 92 | (ms/subset? (ms/multiset 1 2 2 2) (ms/multiset 1 2 2 3 3 4)) => falsey 93 | (ms/subset? #{1 2 3} (ms/multiset 1 2 2 3 3 4)) => truthy 94 | (ms/subset? (ms/multiset 1 2 2) #{1 2 3}) => falsey 95 | (ms/subset? (ms/multiset 1 2) #{1 2}) => truthy) 96 | 97 | (fact "i can haz meta" 98 | (let [m {:foo :bar}] 99 | (meta (with-meta (ms/multiset) m)) => m)) 100 | 101 | (fact "empty retains meta" 102 | (let [m {:foo :bar}] 103 | (meta (empty (with-meta (ms/multiset) m))) => m)) 104 | 105 | (fact "vec works" 106 | (vec (ms/multiset)) => [] 107 | (vec (ms/multiset 9 9)) => [9 9]) 108 | 109 | (fact ".toArray works" 110 | (seq (.toArray (ms/multiset))) => nil 111 | (seq (.toArray (ms/multiset 42 42))) => [42 42]) 112 | -------------------------------------------------------------------------------- /src/main/multiset/core.clj: -------------------------------------------------------------------------------- 1 | (ns multiset.core 2 | "A simple multiset/bag implementation for Clojure." 3 | (:require [clojure.algo.generic.functor :as fu]) 4 | (:import (java.util Collection) 5 | (clojure.lang IPersistentMap))) 6 | 7 | (declare empty-multiset) 8 | 9 | (defprotocol Multiplicities 10 | (multiplicities [this])) 11 | 12 | (deftype MultiSet [^IPersistentMap m 13 | ^IPersistentMap t 14 | ^int size] 15 | 16 | clojure.lang.IPersistentSet ;---------- 17 | (get [this x] 18 | (if-let [e (find t x)] 19 | (key e))) 20 | (contains [this x] 21 | (boolean (find t x))) 22 | (disjoin [this x] 23 | (let [oldcount (get t x)] 24 | (if (not oldcount) 25 | this 26 | (MultiSet. 27 | m 28 | (if (== 1 oldcount) 29 | (dissoc t x) 30 | (assoc t x (dec oldcount))) 31 | (dec size))))) 32 | 33 | clojure.lang.IPersistentCollection ;---------- 34 | (cons [this x] 35 | (MultiSet. 36 | m 37 | (assoc t x (inc (get t x 0))) 38 | (inc size))) 39 | (empty [this] (with-meta empty-multiset m)) 40 | (equiv [this x] (.equals this x)) 41 | 42 | clojure.lang.Seqable ;---------- 43 | (seq [this] 44 | (if-let [entry (first (seq t))] 45 | (let [k (key entry)] 46 | (lazy-seq (cons k (.seq (.disjoin this k))))))) 47 | 48 | clojure.lang.Counted ;---------- 49 | (count [this] size) 50 | 51 | clojure.lang.IMeta ;---------- 52 | (meta [this] m) 53 | 54 | clojure.lang.IObj ;---------- 55 | (withMeta [this m] 56 | (MultiSet. m t size)) 57 | 58 | Object ;---------- 59 | (equals [this x] 60 | (if (instance? MultiSet x) 61 | (.equals t (.t ^MultiSet x)) 62 | false)) 63 | (hashCode [this] 64 | (hash-combine (hash t) MultiSet)) 65 | 66 | clojure.lang.IFn ;---------- 67 | (invoke [this x] 68 | (.get this x)) 69 | (invoke [this x default] 70 | (let [r (.get this x)] 71 | (if r 72 | r 73 | default))) 74 | 75 | Collection ;---------- 76 | (isEmpty [this] 77 | (zero? size)) 78 | (size [this] size) 79 | (^objects toArray [this ^objects a] 80 | (.toArray ^Collection (or (seq this) ()) ^objects a)) 81 | (^objects toArray [^objects this] 82 | (.toArray ^Collection (or (seq this) ()))) 83 | (iterator [this] 84 | (.iterator ^Collection (or (seq this) ()))) 85 | (containsAll [this coll] 86 | (.containsAll ^Collection (into #{} this) coll)) 87 | 88 | Multiplicities ;---------- 89 | (multiplicities [this] t)) 90 | 91 | (def ^:private empty-multiset (MultiSet. nil {} 0)) 92 | 93 | (defn multiset 94 | "Create a multiset with given elements." 95 | [& xs] (into empty-multiset xs)) 96 | 97 | (defn multiplicities->multiset 98 | "Create a multiset from a given multilicities map 99 | (see 'multiplicities')." 100 | [t] (let [mults (into {} (for [[k v] t :when (pos? v)] [k v])) 101 | size (reduce + (vals mults))] 102 | (MultiSet. nil mults size))) 103 | 104 | (defn multiset? 105 | "Return true if x is a multiset, false otherwise." 106 | [x] (instance? MultiSet x)) 107 | 108 | (defn multiplicity 109 | "Return the multiplicity of element x in m, 0 if x is not present." 110 | [m x] (get (multiplicities m) x 0)) 111 | 112 | (defn ^:private mults [coll] 113 | (if (multiset? coll) 114 | (multiplicities coll) 115 | (reduce #(assoc %1 %2 (inc (get %1 %2 0))) {} coll))) 116 | 117 | (defn ^:private msetop [keysfn multfn] 118 | (fn op 119 | ([a b] 120 | (let [a (mults a) 121 | b (mults b) 122 | ks (keysfn (keys a) (keys b))] 123 | (multiplicities->multiset 124 | (->> ks (map #(vector % (multfn a b %))) 125 | (filter #(> (get % 1) 0)) 126 | (into {}))))))) 127 | 128 | (def ^{:arglists '([a b])} intersect 129 | "Return the intersection of a and b as a multiset." 130 | (msetop (fn [a b] a) 131 | #(min (get %1 %3 0) (get %2 %3 0)))) 132 | 133 | (def ^{:arglists '([a b])} union 134 | "Return the union of a and b as a multiset." 135 | (msetop #(-> #{} (into %1) (into %2)) 136 | #(max (get %1 %3 0) (get %2 %3 0)))) 137 | 138 | (def ^{:arglists '([a b])} cartprod 139 | "Return the cartesian product of a and b as a multiset." 140 | (msetop (fn [a b] (mapcat #(map (fn [x] (vector %1 x)) b) a)) 141 | (fn [a b [x y]] (* (get a x 0) (get b y 0))))) 142 | 143 | (def ^{:arglists '([a b])} sum 144 | "Return the multiset sum of a and b as a multiset." 145 | (msetop #(-> #{} (into %1) (into %2)) 146 | #(+ (get %1 %3 0) (get %2 %3 0)))) 147 | 148 | (def ^{:arglists '([a b])} minus 149 | "Return the difference a-b of a and b as a multiset." 150 | (msetop (fn [a b] a) 151 | #(max 0 (- (get %1 %3) (get %2 %3 0))))) 152 | 153 | (defn scale 154 | "Return a multiset in which the multiplicity of each 155 | element in m is scaled by factor k." 156 | [m k] 157 | (when-not (neg? k) 158 | (multiplicities->multiset (fu/fmap #(* k %) (multiplicities m))))) 159 | 160 | (defn subset? 161 | "Return true, if a is a subset of b." 162 | [a b] 163 | (let [a (mults a) 164 | b (mults b)] 165 | (reduce #(and %1 (<= (get a %2) (get b %2 0))) true (keys a)))) 166 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Source code distributed under the Eclipse Public License - v 1.0: 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE 4 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF 5 | THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial code and 12 | documentation distributed under this Agreement, and 13 | 14 | b) in the case of each subsequent Contributor: 15 | 16 | i) changes to the Program, and 17 | 18 | ii) additions to the Program; 19 | 20 | where such changes and/or additions to the Program originate from and 21 | are distributed by that particular Contributor. A Contribution 22 | 'originates' from a Contributor if it was added to the Program by such 23 | Contributor itself or anyone acting on such Contributor's 24 | behalf. Contributions do not include additions to the Program which: 25 | (i) are separate modules of software distributed in conjunction with 26 | the Program under their own license agreement, and (ii) are not 27 | derivative works of the Program. 28 | 29 | "Contributor" means any person or entity that distributes the Program. 30 | 31 | "Licensed Patents" mean patent claims licensable by a Contributor 32 | which are necessarily infringed by the use or sale of its Contribution 33 | alone or when combined with the Program. 34 | 35 | "Program" means the Contributions distributed in accordance with this 36 | Agreement. 37 | 38 | "Recipient" means anyone who receives the Program under this 39 | Agreement, including all Contributors. 40 | 41 | 2. GRANT OF RIGHTS 42 | 43 | a) Subject to the terms of this Agreement, each Contributor hereby 44 | grants Recipient a non-exclusive, worldwide, royalty-free copyright 45 | license to reproduce, prepare derivative works of, publicly display, 46 | publicly perform, distribute and sublicense the Contribution of such 47 | Contributor, if any, and such derivative works, in source code and 48 | object code form. 49 | 50 | b) Subject to the terms of this Agreement, each Contributor hereby 51 | grants Recipient a non-exclusive, worldwide, royalty-free patent 52 | license under Licensed Patents to make, use, sell, offer to sell, 53 | import and otherwise transfer the Contribution of such Contributor, if 54 | any, in source code and object code form. This patent license shall 55 | apply to the combination of the Contribution and the Program if, at 56 | the time the Contribution is added by the Contributor, such addition 57 | of the Contribution causes such combination to be covered by the 58 | Licensed Patents. The patent license shall not apply to any other 59 | combinations which include the Contribution. No hardware per se is 60 | licensed hereunder. 61 | 62 | c) Recipient understands that although each Contributor grants the 63 | licenses to its Contributions set forth herein, no assurances are 64 | provided by any Contributor that the Program does not infringe the 65 | patent or other intellectual property rights of any other entity. Each 66 | Contributor disclaims any liability to Recipient for claims brought by 67 | any other entity based on infringement of intellectual property rights 68 | or otherwise. As a condition to exercising the rights and licenses 69 | granted hereunder, each Recipient hereby assumes sole responsibility 70 | to secure any other intellectual property rights needed, if any. For 71 | example, if a third party patent license is required to allow 72 | Recipient to distribute the Program, it is Recipient's responsibility 73 | to acquire that license before distributing the Program. 74 | 75 | d) Each Contributor represents that to its knowledge it has sufficient 76 | copyright rights in its Contribution, if any, to grant the copyright 77 | license set forth in this Agreement. 78 | 79 | 3. REQUIREMENTS 80 | 81 | A Contributor may choose to distribute the Program in object code form 82 | under its own license agreement, provided that: 83 | 84 | a) it complies with the terms and conditions of this Agreement; and 85 | 86 | b) its license agreement: 87 | 88 | i) effectively disclaims on behalf of all Contributors all warranties 89 | and conditions, express and implied, including warranties or 90 | conditions of title and non-infringement, and implied warranties or 91 | conditions of merchantability and fitness for a particular purpose; 92 | 93 | ii) effectively excludes on behalf of all Contributors all liability 94 | for damages, including direct, indirect, special, incidental and 95 | consequential damages, such as lost profits; 96 | 97 | iii) states that any provisions which differ from this Agreement are 98 | offered by that Contributor alone and not by any other party; and 99 | 100 | iv) states that source code for the Program is available from such 101 | Contributor, and informs licensees how to obtain it in a reasonable 102 | manner on or through a medium customarily used for software exchange. 103 | 104 | When the Program is made available in source code form: 105 | 106 | a) it must be made available under this Agreement; and 107 | 108 | b) a copy of this Agreement must be included with each copy of the Program. 109 | 110 | Contributors may not remove or alter any copyright notices contained 111 | within the Program. 112 | 113 | Each Contributor must identify itself as the originator of its 114 | Contribution, if any, in a manner that reasonably allows subsequent 115 | Recipients to identify the originator of the Contribution. 116 | 117 | 4. COMMERCIAL DISTRIBUTION 118 | 119 | Commercial distributors of software may accept certain 120 | responsibilities with respect to end users, business partners and the 121 | like. While this license is intended to facilitate the commercial use 122 | of the Program, the Contributor who includes the Program in a 123 | commercial product offering should do so in a manner which does not 124 | create potential liability for other Contributors. Therefore, if a 125 | Contributor includes the Program in a commercial product offering, 126 | such Contributor ("Commercial Contributor") hereby agrees to defend 127 | and indemnify every other Contributor ("Indemnified Contributor") 128 | against any losses, damages and costs (collectively "Losses") arising 129 | from claims, lawsuits and other legal actions brought by a third party 130 | against the Indemnified Contributor to the extent caused by the acts 131 | or omissions of such Commercial Contributor in connection with its 132 | distribution of the Program in a commercial product offering. The 133 | obligations in this section do not apply to any claims or Losses 134 | relating to any actual or alleged intellectual property 135 | infringement. In order to qualify, an Indemnified Contributor must: a) 136 | promptly notify the Commercial Contributor in writing of such claim, 137 | and b) allow the Commercial Contributor tocontrol, and cooperate with 138 | the Commercial Contributor in, the defense and any related settlement 139 | negotiations. The Indemnified Contributor may participate in any such 140 | claim at its own expense. 141 | 142 | For example, a Contributor might include the Program in a commercial 143 | product offering, Product X. That Contributor is then a Commercial 144 | Contributor. If that Commercial Contributor then makes performance 145 | claims, or offers warranties related to Product X, those performance 146 | claims and warranties are such Commercial Contributor's responsibility 147 | alone. Under this section, the Commercial Contributor would have to 148 | defend claims against the other Contributors related to those 149 | performance claims and warranties, and if a court requires any other 150 | Contributor to pay any damages as a result, the Commercial Contributor 151 | must pay those damages. 152 | 153 | 5. NO WARRANTY 154 | 155 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS 156 | PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 157 | KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 158 | WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY 159 | OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely 160 | responsible for determining the appropriateness of using and 161 | distributing the Program and assumes all risks associated with its 162 | exercise of rights under this Agreement , including but not limited to 163 | the risks and costs of program errors, compliance with applicable 164 | laws, damage to or loss of data, programs or equipment, and 165 | unavailability or interruption of operations. 166 | 167 | 6. DISCLAIMER OF LIABILITY 168 | 169 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR 170 | ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, 171 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING 172 | WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF 173 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 174 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR 175 | DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 176 | HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 177 | 178 | 7. GENERAL 179 | 180 | If any provision of this Agreement is invalid or unenforceable under 181 | applicable law, it shall not affect the validity or enforceability of 182 | the remainder of the terms of this Agreement, and without further 183 | action by the parties hereto, such provision shall be reformed to the 184 | minimum extent necessary to make such provision valid and enforceable. 185 | 186 | If Recipient institutes patent litigation against any entity 187 | (including a cross-claim or counterclaim in a lawsuit) alleging that 188 | the Program itself (excluding combinations of the Program with other 189 | software or hardware) infringes such Recipient's patent(s), then such 190 | Recipient's rights granted under Section 2(b) shall terminate as of 191 | the date such litigation is filed. 192 | 193 | All Recipient's rights under this Agreement shall terminate if it 194 | fails to comply with any of the material terms or conditions of this 195 | Agreement and does not cure such failure in a reasonable period of 196 | time after becoming aware of such noncompliance. If all Recipient's 197 | rights under this Agreement terminate, Recipient agrees to cease use 198 | and distribution of the Program as soon as reasonably 199 | practicable. However, Recipient's obligations under this Agreement and 200 | any licenses granted by Recipient relating to the Program shall 201 | continue and survive. 202 | 203 | Everyone is permitted to copy and distribute copies of this Agreement, 204 | but in order to avoid inconsistency the Agreement is copyrighted and 205 | may only be modified in the following manner. The Agreement Steward 206 | reserves the right to publish new versions (including revisions) of 207 | this Agreement from time to time. No one other than the Agreement 208 | Steward has the right to modify this Agreement. The Eclipse Foundation 209 | is the initial Agreement Steward. The Eclipse Foundation may assign 210 | the responsibility to serve as the Agreement Steward to a suitable 211 | separate entity. Each new version of the Agreement will be given a 212 | distinguishing version number. The Program (including Contributions) 213 | may always be distributed subject to the version of the Agreement 214 | under which it was received. In addition, after a new version of the 215 | Agreement is published, Contributor may elect to distribute the 216 | Program (including its Contributions) under the new version. Except as 217 | expressly stated in Sections 2(a) and 2(b) above, Recipient receives 218 | no rights or licenses to the intellectual property of any Contributor 219 | under this Agreement, whether expressly, by implication, estoppel or 220 | otherwise. All rights in the Program not expressly granted under this 221 | Agreement are reserved. 222 | 223 | This Agreement is governed by the laws of the State of Washington and 224 | the intellectual property laws of the United States of America. No 225 | party to this Agreement will bring a legal action under this Agreement 226 | more than one year after the cause of action arose. Each party waives 227 | its rights to a jury trial in any resulting litigation. 228 | 229 | 230 | 231 | Images distributed under the Creative Commons Attribution + ShareAlike 232 | License version 3.0: 233 | 234 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS 235 | CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS 236 | PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE 237 | WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS 238 | PROHIBITED. 239 | 240 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND 241 | AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS 242 | LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU 243 | THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH 244 | TERMS AND CONDITIONS. 245 | 246 | 1. Definitions 247 | 248 | "Adaptation" means a work based upon the Work, or upon the Work 249 | and other pre-existing works, such as a translation, adaptation, 250 | derivative work, arrangement of music or other alterations of a 251 | literary or artistic work, or phonogram or performance and 252 | includes cinematographic adaptations or any other form in which 253 | the Work may be recast, transformed, or adapted including in any 254 | form recognizably derived from the original, except that a work 255 | that constitutes a Collection will not be considered an Adaptation 256 | for the purpose of this License. For the avoidance of doubt, where 257 | the Work is a musical work, performance or phonogram, the 258 | synchronization of the Work in timed-relation with a moving image 259 | ("synching") will be considered an Adaptation for the purpose of 260 | this License. 261 | 262 | "Collection" means a collection of literary or artistic works, 263 | such as encyclopedias and anthologies, or performances, phonograms 264 | or broadcasts, or other works or subject matter other than works 265 | listed in Section 1(f) below, which, by reason of the selection 266 | and arrangement of their contents, constitute intellectual 267 | creations, in which the Work is included in its entirety in 268 | unmodified form along with one or more other contributions, each 269 | constituting separate and independent works in themselves, which 270 | together are assembled into a collective whole. A work that 271 | constitutes a Collection will not be considered an Adaptation (as 272 | defined below) for the purposes of this License. 273 | 274 | "Creative Commons Compatible License" means a license that is 275 | listed at http://creativecommons.org/compatiblelicenses that has 276 | been approved by Creative Commons as being essentially equivalent 277 | to this License, including, at a minimum, because that license: 278 | (i) contains terms that have the same purpose, meaning and effect 279 | as the License Elements of this License; and, (ii) explicitly 280 | permits the relicensing of adaptations of works made available 281 | under that license under this License or a Creative Commons 282 | jurisdiction license with the same License Elements as this 283 | License. 284 | 285 | "Distribute" means to make available to the public the original 286 | and copies of the Work or Adaptation, as appropriate, through sale 287 | or other transfer of ownership. 288 | 289 | "License Elements" means the following high-level license 290 | attributes as selected by Licensor and indicated in the title of 291 | this License: Attribution, ShareAlike. 292 | 293 | "Licensor" means the individual, individuals, entity or entities 294 | that offer(s) the Work under the terms of this License. 295 | 296 | "Original Author" means, in the case of a literary or artistic 297 | work, the individual, individuals, entity or entities who created 298 | the Work or if no individual or entity can be identified, the 299 | publisher; and in addition (i) in the case of a performance the 300 | actors, singers, musicians, dancers, and other persons who act, 301 | sing, deliver, declaim, play in, interpret or otherwise perform 302 | literary or artistic works or expressions of folklore; (ii) in the 303 | case of a phonogram the producer being the person or legal entity 304 | who first fixes the sounds of a performance or other sounds; and, 305 | (iii) in the case of broadcasts, the organization that transmits 306 | the broadcast. 307 | 308 | "Work" means the literary and/or artistic work offered under the 309 | terms of this License including without limitation any production 310 | in the literary, scientific and artistic domain, whatever may be 311 | the mode or form of its expression including digital form, such as 312 | a book, pamphlet and other writing; a lecture, address, sermon or 313 | other work of the same nature; a dramatic or dramatico-musical 314 | work; a choreographic work or entertainment in dumb show; a 315 | musical composition with or without words; a cinematographic work 316 | to which are assimilated works expressed by a process analogous to 317 | cinematography; a work of drawing, painting, architecture, 318 | sculpture, engraving or lithography; a photographic work to which 319 | are assimilated works expressed by a process analogous to 320 | photography; a work of applied art; an illustration, map, plan, 321 | sketch or three-dimensional work relative to geography, 322 | topography, architecture or science; a performance; a broadcast; a 323 | phonogram; a compilation of data to the extent it is protected as 324 | a copyrightable work; or a work performed by a variety or circus 325 | performer to the extent it is not otherwise considered a literary 326 | or artistic work. 327 | 328 | "You" means an individual or entity exercising rights under this 329 | License who has not previously violated the terms of this License 330 | with respect to the Work, or who has received express permission 331 | from the Licensor to exercise rights under this License despite a 332 | previous violation. 333 | 334 | "Publicly Perform" means to perform public recitations of the Work 335 | and to communicate to the public those public recitations, by any 336 | means or process, including by wire or wireless means or public 337 | digital performances; to make available to the public Works in 338 | such a way that members of the public may access these Works from 339 | a place and at a place individually chosen by them; to perform the 340 | Work to the public by any means or process and the communication 341 | to the public of the performances of the Work, including by public 342 | digital performance; to broadcast and rebroadcast the Work by any 343 | means including signs, sounds or images. 344 | 345 | "Reproduce" means to make copies of the Work by any means 346 | including without limitation by sound or visual recordings and the 347 | right of fixation and reproducing fixations of the Work, including 348 | storage of a protected performance or phonogram in digital form or 349 | other electronic medium. 350 | 351 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, 352 | limit, or restrict any uses free from copyright or rights arising from 353 | limitations or exceptions that are provided for in connection with the 354 | copyright protection under copyright law or other applicable laws. 355 | 356 | 3. License Grant. Subject to the terms and conditions of this License, 357 | Licensor hereby grants You a worldwide, royalty-free, non-exclusive, 358 | perpetual (for the duration of the applicable copyright) license to 359 | exercise the rights in the Work as stated below: 360 | 361 | to Reproduce the Work, to incorporate the Work into one or more 362 | Collections, and to Reproduce the Work as incorporated in the 363 | Collections; 364 | 365 | to create and Reproduce Adaptations provided that any such 366 | Adaptation, including any translation in any medium, takes 367 | reasonable steps to clearly label, demarcate or otherwise identify 368 | that changes were made to the original Work. For example, a 369 | translation could be marked "The original work was translated from 370 | English to Spanish," or a modification could indicate "The 371 | original work has been modified."; 372 | 373 | to Distribute and Publicly Perform the Work including as 374 | incorporated in Collections; and, 375 | 376 | to Distribute and Publicly Perform Adaptations. 377 | 378 | For the avoidance of doubt: 379 | 380 | Non-waivable Compulsory License Schemes. In those 381 | jurisdictions in which the right to collect royalties through 382 | any statutory or compulsory licensing scheme cannot be waived, 383 | the Licensor reserves the exclusive right to collect such 384 | royalties for any exercise by You of the rights granted under 385 | this License; 386 | 387 | Waivable Compulsory License Schemes. In those jurisdictions in 388 | which the right to collect royalties through any statutory or 389 | compulsory licensing scheme can be waived, the Licensor waives 390 | the exclusive right to collect such royalties for any exercise 391 | by You of the rights granted under this License; and, 392 | 393 | Voluntary License Schemes. The Licensor waives the right to 394 | collect royalties, whether individually or, in the event that 395 | the Licensor is a member of a collecting society that 396 | administers voluntary licensing schemes, via that society, 397 | from any exercise by You of the rights granted under this 398 | License. 399 | 400 | The above rights may be exercised in all media and formats whether now 401 | known or hereafter devised. The above rights include the right to make 402 | such modifications as are technically necessary to exercise the rights 403 | in other media and formats. Subject to Section 8(f), all rights not 404 | expressly granted by Licensor are hereby reserved. 405 | 406 | 4. Restrictions. The license granted in Section 3 above is expressly 407 | made subject to and limited by the following restrictions: 408 | 409 | You may Distribute or Publicly Perform the Work only under the 410 | terms of this License. You must include a copy of, or the Uniform 411 | Resource Identifier (URI) for, this License with every copy of the 412 | Work You Distribute or Publicly Perform. You may not offer or 413 | impose any terms on the Work that restrict the terms of this 414 | License or the ability of the recipient of the Work to exercise 415 | the rights granted to that recipient under the terms of the 416 | License. You may not sublicense the Work. You must keep intact all 417 | notices that refer to this License and to the disclaimer of 418 | warranties with every copy of the Work You Distribute or Publicly 419 | Perform. When You Distribute or Publicly Perform the Work, You may 420 | not impose any effective technological measures on the Work that 421 | restrict the ability of a recipient of the Work from You to 422 | exercise the rights granted to that recipient under the terms of 423 | the License. This Section 4(a) applies to the Work as incorporated 424 | in a Collection, but this does not require the Collection apart 425 | from the Work itself to be made subject to the terms of this 426 | License. If You create a Collection, upon notice from any Licensor 427 | You must, to the extent practicable, remove from the Collection 428 | any credit as required by Section 4(c), as requested. If You 429 | create an Adaptation, upon notice from any Licensor You must, to 430 | the extent practicable, remove from the Adaptation any credit as 431 | required by Section 4(c), as requested. 432 | 433 | You may Distribute or Publicly Perform an Adaptation only under 434 | the terms of: (i) this License; (ii) a later version of this 435 | License with the same License Elements as this License; (iii) a 436 | Creative Commons jurisdiction license (either this or a later 437 | license version) that contains the same License Elements as this 438 | License (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative 439 | Commons Compatible License. If you license the Adaptation under 440 | one of the licenses mentioned in (iv), you must comply with the 441 | terms of that license. If you license the Adaptation under the 442 | terms of any of the licenses mentioned in (i), (ii) or (iii) (the 443 | "Applicable License"), you must comply with the terms of the 444 | Applicable License generally and the following provisions: (I) You 445 | must include a copy of, or the URI for, the Applicable License 446 | with every copy of each Adaptation You Distribute or Publicly 447 | Perform; (II) You may not offer or impose any terms on the 448 | Adaptation that restrict the terms of the Applicable License or 449 | the ability of the recipient of the Adaptation to exercise the 450 | rights granted to that recipient under the terms of the Applicable 451 | License; (III) You must keep intact all notices that refer to the 452 | Applicable License and to the disclaimer of warranties with every 453 | copy of the Work as included in the Adaptation You Distribute or 454 | Publicly Perform; (IV) when You Distribute or Publicly Perform the 455 | Adaptation, You may not impose any effective technological 456 | measures on the Adaptation that restrict the ability of a 457 | recipient of the Adaptation from You to exercise the rights 458 | granted to that recipient under the terms of the Applicable 459 | License. This Section 4(b) applies to the Adaptation as 460 | incorporated in a Collection, but this does not require the 461 | Collection apart from the Adaptation itself to be made subject to 462 | the terms of the Applicable License. 463 | 464 | If You Distribute, or Publicly Perform the Work or any Adaptations 465 | or Collections, You must, unless a request has been made pursuant 466 | to Section 4(a), keep intact all copyright notices for the Work 467 | and provide, reasonable to the medium or means You are utilizing: 468 | (i) the name of the Original Author (or pseudonym, if applicable) 469 | if supplied, and/or if the Original Author and/or Licensor 470 | designate another party or parties (e.g., a sponsor institute, 471 | publishing entity, journal) for attribution ("Attribution 472 | Parties") in Licensor's copyright notice, terms of service or by 473 | other reasonable means, the name of such party or parties; (ii) 474 | the title of the Work if supplied; (iii) to the extent reasonably 475 | practicable, the URI, if any, that Licensor specifies to be 476 | associated with the Work, unless such URI does not refer to the 477 | copyright notice or licensing information for the Work; and (iv) , 478 | consistent with Ssection 3(b), in the case of an Adaptation, a 479 | credit identifying the use of the Work in the Adaptation (e.g., 480 | "French translation of the Work by Original Author," or 481 | "Screenplay based on original Work by Original Author"). The 482 | credit required by this Section 4(c) may be implemented in any 483 | reasonable manner; provided, however, that in the case of a 484 | Adaptation or Collection, at a minimum such credit will appear, if 485 | a credit for all contributing authors of the Adaptation or 486 | Collection appears, then as part of these credits and in a manner 487 | at least as prominent as the credits for the other contributing 488 | authors. For the avoidance of doubt, You may only use the credit 489 | required by this Section for the purpose of attribution in the 490 | manner set out above and, by exercising Your rights under this 491 | License, You may not implicitly or explicitly assert or imply any 492 | connection with, sponsorship or endorsement by the Original 493 | Author, Licensor and/or Attribution Parties, as appropriate, of 494 | You or Your use of the Work, without the separate, express prior 495 | written permission of the Original Author, Licensor and/or 496 | Attribution Parties. 497 | 498 | Except as otherwise agreed in writing by the Licensor or as may be 499 | otherwise permitted by applicable law, if You Reproduce, 500 | Distribute or Publicly Perform the Work either by itself or as 501 | part of any Adaptations or Collections, You must not distort, 502 | mutilate, modify or take other derogatory action in relation to 503 | the Work which would be prejudicial to the Original Author's honor 504 | or reputation. Licensor agrees that in those jurisdictions 505 | (e.g. Japan), in which any exercise of the right granted in 506 | Section 3(b) of this License (the right to make Adaptations) would 507 | be deemed to be a distortion, mutilation, modification or other 508 | derogatory action prejudicial to the Original Author's honor and 509 | reputation, the Licensor will waive or not assert, as appropriate, 510 | this Section, to the fullest extent permitted by the applicable 511 | national law, to enable You to reasonably exercise Your right 512 | under Section 3(b) of this License (right to make Adaptations) but 513 | not otherwise. 514 | 515 | 5. Representations, Warranties and Disclaimer 516 | 517 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, 518 | LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR 519 | WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, 520 | STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF 521 | TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, 522 | NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, 523 | OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT 524 | DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED 525 | WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 526 | 527 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY 528 | APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY 529 | LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR 530 | EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, 531 | EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 532 | 533 | 7. Termination 534 | 535 | This License and the rights granted hereunder will terminate 536 | automatically upon any breach by You of the terms of this 537 | License. Individuals or entities who have received Adaptations or 538 | Collections from You under this License, however, will not have 539 | their licenses terminated provided such individuals or entities 540 | remain in full compliance with those licenses. Sections 1, 2, 5, 541 | 6, 7, and 8 will survive any termination of this License. 542 | 543 | Subject to the above terms and conditions, the license granted 544 | here is perpetual (for the duration of the applicable copyright in 545 | the Work). Notwithstanding the above, Licensor reserves the right 546 | to release the Work under different license terms or to stop 547 | distributing the Work at any time; provided, however that any such 548 | election will not serve to withdraw this License (or any other 549 | license that has been, or is required to be, granted under the 550 | terms of this License), and this License will continue in full 551 | force and effect unless terminated as stated above. 552 | 553 | 8. Miscellaneous 554 | 555 | Each time You Distribute or Publicly Perform the Work or a 556 | Collection, the Licensor offers to the recipient a license to the 557 | Work on the same terms and conditions as the license granted to 558 | You under this License. 559 | 560 | Each time You Distribute or Publicly Perform an Adaptation, 561 | Licensor offers to the recipient a license to the original Work on 562 | the same terms and conditions as the license granted to You under 563 | this License. 564 | 565 | If any provision of this License is invalid or unenforceable under 566 | applicable law, it shall not affect the validity or enforceability 567 | of the remainder of the terms of this License, and without further 568 | action by the parties to this agreement, such provision shall be 569 | reformed to the minimum extent necessary to make such provision 570 | valid and enforceable. 571 | 572 | No term or provision of this License shall be deemed waived and no 573 | breach consented to unless such waiver or consent shall be in 574 | writing and signed by the party to be charged with such waiver or 575 | consent. 576 | 577 | This License constitutes the entire agreement between the parties 578 | with respect to the Work licensed here. There are no 579 | understandings, agreements or representations with respect to the 580 | Work not specified here. Licensor shall not be bound by any 581 | additional provisions that may appear in any communication from 582 | You. This License may not be modified without the mutual written 583 | agreement of the Licensor and You. 584 | 585 | The rights granted under, and the subject matter referenced, in 586 | this License were drafted utilizing the terminology of the Berne 587 | Convention for the Protection of Literary and Artistic Works (as 588 | amended on September 28, 1979), the Rome Convention of 1961, the 589 | WIPO Copyright Treaty of 1996, the WIPO Performances and 590 | Phonograms Treaty of 1996 and the Universal Copyright Convention 591 | (as revised on July 24, 1971). These rights and subject matter 592 | take effect in the relevant jurisdiction in which the License 593 | terms are sought to be enforced according to the corresponding 594 | provisions of the implementation of those treaty provisions in the 595 | applicable national law. If the standard suite of rights granted 596 | under applicable copyright law includes additional rights not 597 | granted under this License, such additional rights are deemed to 598 | be included in the License; this License is not intended to 599 | restrict the license of any rights under applicable law. --------------------------------------------------------------------------------