A more mathematical kind of set object in clojure
Hi All, First time poster in this google group. I'm looking for a slightly different kind of* set* than the set collection offered in clojure.core. Whilst the latter is great for finite sets, I'm looking for a package that implements uncountable sets i.e. the set of real numbers less than 44. This can be defined using a predicate i.e. an element x belongs to this set if the predicate (< x 44) evaluated to true. Unions and intersections of such sets correspond to logical ands and ors of the corresponding predicates. I could have a go at implementing this myself, but I am wondering if there is an existing tested library for dealing with such objects. Thanks! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: A more mathematical kind of set object in clojure
There is a talk by Alex Engelberg about constraint solvers and his clojure interface to one of them: https://github.com/aengelberg/loco https://www.youtube.com/watch?v=AEhULv4ruL4 I'm not quite familiar with it, but maybe it's relevant to your requirements. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: A more mathematical kind of set object in clojure
core.logic's CLP(FD) extensions, for finite domains, might also suit your needs: https://github.com/clojure/core.logic/wiki/Features#clpfd -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: A more mathematical kind of set object in clojure
Not quite what I'm looking for. There is an assigment in the Functional Programming in Scala coursera course called "funsets" - purely functional sets. A set is defined by its characteristic functions (a predicate) and source code can be found here https://mwclearning.com/sourcecode/scala/funsets/src/main/scala/funsets/FunSets.scala this is the sort of thing I am looking for. On Saturday, January 28, 2017 at 5:06:49 PM UTC-5, Herwig Hochleitner wrote: > > core.logic's CLP(FD) extensions, for finite domains, might also suit your > needs: https://github.com/clojure/core.logic/wiki/Features#clpfd > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: A more mathematical kind of set object in clojure
Am 29.01.2017 um 21:15 schrieb Michael Lindon: > Not quite what I'm looking for. There is an assigment in the Functional > Programming in Scala coursera course called "funsets" - purely > functional sets. A set is defined by its characteristic functions (a > predicate) and source code can be found here > > https://mwclearning.com/sourcecode/scala/funsets/src/main/scala/funsets/FunSets.scala > > this is the sort of thing I am looking for. What do you expect exactly from such an implementation? The definition by the characteristic function might make elements of a set in theory computably enumerable, but it is not practical to get a materialized view. You can only query membership. Maybe if you can create a persistent datastructure over characteristic functions you can actually compose such a datastructure, but in fact you just compose predicates (as is also done in FunSets.scala) and reify them as a type there. If you just want such an implementation to fulfill part of Clojure's contracts for sets, you would implement the corresponding interface: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IPersistentSet.java But you would have to throw on some of these methods and I am not sure what the benefits are. You can always create new interfaces (protocols) ofc. Do you have a concrete problem in mind? Best, Christian -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. signature.asc Description: OpenPGP digital signature
Re: A more mathematical kind of set object in clojure
2017-01-29 21:15 GMT+01:00 Michael Lindon : > Not quite what I'm looking for. There is an assigment in the Functional > Programming in Scala coursera course called "funsets" - purely functional > sets. A set is defined by its characteristic functions (a predicate) and > source code can be found here > Looking at it from a functional perspective, it still might be though. Consider: You can treat any set as a predicate, but to treat a predicate as a set, you need to add enumeration (as Christian hinted). https://mwclearning.com/sourcecode/scala/funsets/src/ > main/scala/funsets/FunSets.scala > The enumeration scheme in this scala object is very simplistic: It works for integers between -1000 and 1000. Besides being incomplete, this can easily lead to unnecessarily exponential runtimes: > /** > * The bounds for `forall` and `exists` are +/- 1000. > */ > val bound = 1000 > /** > * Returns whether all bounded integers within `s` satisfy `p`. > */ > def forall(s: Set, p: Int => Boolean): Boolean = { > val filteredSet = filter(s, p) > def iter(a: Int): Boolean = { > if (contains(s, a) && !contains(filteredSet, a)) false > else if (a > bound) true > else iter(a + 1) > } > iter(-bound) > } > /** > * Returns whether there exists a bounded integer within `s` > * that satisfies `p`. > */ > def exists(s: Set, p: Int => Boolean): Boolean = forall(s, union(s,p)) Constraint programming offers a much more sophisticated approach towards enumeration, eagerly skipping whole subsets based on excluded ranges. Maybe that's what the coursera is aiming for ... -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.