Re: math expression simplifier, kibit implementation

2012-12-02 Thread David Nolen
On Sun, Dec 2, 2012 at 1:42 PM, Jonas wrote: > > > On Sunday, December 2, 2012 7:33:17 PM UTC+2, David Nolen wrote: > >> On Sat, Dec 1, 2012 at 12:24 AM, Jonas wrote: >> >>> >>> * Predicates on logic vars: >>> [(foo (? x number?)) (bar ?x)] => match (foo 42) but not (foo :bar) >>> >> >> This

Re: math expression simplifier, kibit implementation

2012-12-02 Thread Jonas
On Sunday, December 2, 2012 7:33:17 PM UTC+2, David Nolen wrote: > > On Sat, Dec 1, 2012 at 12:24 AM, Jonas >wrote: > >> >> * Predicates on logic vars: >> [(foo (? x number?)) (bar ?x)] => match (foo 42) but not (foo :bar) >> > > This is now possible since we have constraints. > Awesome. I

Re: math expression simplifier, kibit implementation

2012-12-02 Thread David Nolen
On Sat, Dec 1, 2012 at 12:24 AM, Jonas wrote: > > * Predicates on logic vars: > [(foo (? x number?)) (bar ?x)] => match (foo 42) but not (foo :bar) > This is now possible since we have constraints. > * Segment vars: > [(* ??x 1 ??y) (* ??x ??y)] => (* 4 3 2 1 2 3 4) would turn into (*

Re: math expression simplifier, kibit implementation

2012-11-30 Thread Jonas
Hi The function `simplify-one` in kibit.core is the “brain” behind kibit: (defn simplify-one [expr rules] (let [alts (logic/run* [q] (logic/fresh [pat subst] (logic/membero [pat subst] rules) (logic/project [pat subst] (logic/all (pat expr)

Re: math

2012-10-10 Thread Michael Klishin
2012/10/11 kovas boguta > Looks neat. Can I make a suggestion? > > For these cookbooks, it would be very help to know exactly which > version of clojure (and any libraries used) were used. You can even > just put the associated project.clj content at the top. > > putting project.clj in them is co

Re: math

2012-10-10 Thread kovas boguta
Looks neat. Can I make a suggestion? For these cookbooks, it would be very help to know exactly which version of clojure (and any libraries used) were used. You can even just put the associated project.clj content at the top. That way one will have confidence that this is up-to-date info, and kno

Re: math

2012-10-10 Thread John Gabriele
On Tuesday, October 9, 2012 10:38:20 PM UTC-4, Brian Craft wrote: > > I need some basic math functions, e.g. floor. I see there are some in > contrib, but I'm unable to figure out the status of contrib. Seems like > it's deprecated, or in transition, or something? To help answer questions like

Re: math

2012-10-10 Thread Tom Clark
Probably the best way to get basic maths functions in Clojure is to use java.lang.Math. Cheers, Tom On Wed, Oct 10, 2012 at 3:38 PM, Brian Craft wrote: > I need some basic math functions, e.g. floor. I see there are some in > contrib, but I'm unable to figure out the status of contrib. Seems lik

Re: math

2012-10-10 Thread zcaudate
The apache commons library - http://commons.apache.org/math/ is really rock solid. all the utilities can be found in: http://commons.apache.org/math/apidocs/org/apache/commons/math3/util/FastMath.html see http://stackoverflow.com/questions/12327120/finding-all-the-power-roots-in-clojure for a

Re: math

2012-10-09 Thread Mark Engelberg
On Tue, Oct 9, 2012 at 9:03 PM, kovas boguta wrote: > The reality is that the function names and signatures are often > totally different. Just switching the namespaces ain't gonna work. > These are basically new libraries, that are thematically similar to > the old ones. > > The math library has

Re: math

2012-10-09 Thread Sean Corfield
On Tue, Oct 9, 2012 at 9:43 PM, kovas boguta wrote: > Actually all the examples I had in mind where from 1.2 (I migrated > from 1.1 so it all seemed part of a piece to me) > I think the migration from 1.2 to 1.3 is better documented than the migration from 1.1 to 1.2... > So should we expect t

Re: math

2012-10-09 Thread kovas boguta
Alright, you got me on that one. Actually all the examples I had in mind where from 1.2 (I migrated from 1.1 so it all seemed part of a piece to me) So should we expect the function and their signatures to be the same then? On Wed, Oct 10, 2012 at 12:34 AM, Sean Corfield wrote: > On Tue, Oct 9

Re: math

2012-10-09 Thread Sean Corfield
On Tue, Oct 9, 2012 at 9:23 PM, kovas boguta wrote: > The one that bit me specifically was clojure.contrib.string => > clojure.string . Not criticising the new design, its just a fact that > its not backwards compatible. > I believe that happened in Clojure 1.2, even before monolithic contrib wa

Re: math

2012-10-09 Thread Sean Corfield
On Tue, Oct 9, 2012 at 9:22 PM, Brian Craft wrote: > Top hits on google. "clojure math floor", top three hits are contrib docs. > Thanx. I Googled that phrased and the first result was the old richhickey repo. We should be able to get that fixed - or at least a notice added linking to the new co

Re: math

2012-10-09 Thread kovas boguta
The one that bit me specifically was clojure.contrib.string => clojure.string . Not criticising the new design, its just a fact that its not backwards compatible. Anyway the point is: we should make clear that this isn't a 1-to-1 migration. 50% (or even 90%) compatibility is not the same as 100%.

Re: math

2012-10-09 Thread Brian Craft
On Tuesday, October 9, 2012 8:35:28 PM UTC-7, Sean Corfield wrote: > > What would help us is knowing what path you took in looking for > information about the math functions that led you to old contrib... so we > can make adjustments to what documentation is out there to make the new > structu

Re: math

2012-10-09 Thread Sean Corfield
On Tue, Oct 9, 2012 at 9:03 PM, kovas boguta wrote: > Most of the time you are using the contrib for some convenience > function. Its way easier to just copy that function into your own > project, than to worry about tracking down the new library, and then > checking that the function in question

Re: math

2012-10-09 Thread kovas boguta
Honestly the best bet for migrating from old contrib: Find the old contrib on github, and just copy the function or 2 that you want. Anything else is gonna be a frustrating PITA. Its highly misleading to say that the old contrib was broken up to be more modular. The reality is that the function

Re: math

2012-10-09 Thread Sean Corfield
On Tue, Oct 9, 2012 at 7:38 PM, Brian Craft wrote: > I need some basic math functions, e.g. floor. I see there are some in > contrib, but I'm unable to figure out the status of contrib. Seems like > it's deprecated, or in transition, or something? Back with Clojure 1.3, the old monolithic contr

Re: math

2012-10-09 Thread Devin Walters
As long as we're talking about docs lately, I would like to underscore that the transition to modular contrib is still confusing to newcomers. Sorry to hijack the OP's thread, but I think this needs to be dealt with. Suggestions on how to make this more visible or negate the need for understandi

Re: math

2012-10-09 Thread Mark Engelberg
https://github.com/clojure/math.numeric-tower [org.clojure/math.numeric-tower "0.0.1"] On Tue, Oct 9, 2012 at 7:38 PM, Brian Craft wrote: > I need some basic math functions, e.g. floor. I see there are some in > contrib, but I'm unable to figure out the status of contrib. Seems like > it's de

Re: math utilities question

2010-12-06 Thread Joonas Pulakka
Standard way, definitely no. As others have pointed out, Incanter is The Clojure Math Tool, but strongly biased towards statistics and linear algebra, and outside those fields you'll need other tools. Apache Commons Math (http://commons.apache.org/math/) is one of the better self-contained Java ma

Re: math utilities question

2010-12-06 Thread Ken Wesson
(defmacro defchunk [name tps] `(def ~name (quote ~tps))) (defmacro let-chunk [vname name val-vec & body] (let [chunk-def @(resolve name) types (map first chunk-def) part-names (map (comp symbol (partial str vname "!") second) chunk-def)] `(let [~vname ~val-vec ~@

Re: math utilities question

2010-12-06 Thread Ken Wesson
On Tue, Dec 7, 2010 at 12:58 AM, Konrad Hinsen wrote: > On 06.12.2010, at 22:35, Ken Wesson wrote: > >>> I'd say what Java needs is not complex numbers as a value type, but a way >>> to define additional value types. Complex numbers are just one >>> applications. Another one is points (2D or 3D)

Re: math utilities question

2010-12-06 Thread Konrad Hinsen
On 06.12.2010, at 22:35, Ken Wesson wrote: >> I'd say what Java needs is not complex numbers as a value type, but a way to >> define additional value types. Complex numbers are just one applications. >> Another one is points (2D or 3D) for geometry and graphics. >> >> Unfortunately the problem

Re: math utilities question

2010-12-06 Thread Ken Wesson
On Mon, Dec 6, 2010 at 11:45 AM, Konrad Hinsen wrote: > On 06.12.2010, at 16:02, Johann Hibschman wrote: >> Maybe I'm not reading the right news, but I've not seen all that much on >> using Java for scientific work for a while now.  The NIST JavaNumerics >> guys seem to have given up, but if I rem

Re: math utilities question

2010-12-06 Thread Konrad Hinsen
On 06.12.2010, at 16:02, Johann Hibschman wrote: > (Konrad Hinsen had started some work on multiarrays in Clojure, but I've > not been following his progress.) There hasn't been much, unfortunately. I haven't found much time for serious Clojure hacking for a few months. But the project is not ab

Re: math utilities question

2010-12-06 Thread Johann Hibschman
Robert McIntyre writes: > I'm wondering if people have had experience with java libraries of > that sort and might have some recommendations. > > Anyone use clojure for scientific data analysis? What do you find > helpful to use? I'm still just evaluating clojure for scientific data analysis, bu

Re: math utilities question

2010-12-06 Thread Robert McIntyre
I have looked at incanter and like it very much, but these are all things that incanter can't currently do. --Robert McIntyre On Mon, Dec 6, 2010 at 3:15 AM, Saul Hazledine wrote: > On Dec 6, 12:27 am, Robert McIntyre wrote: >> I'm trying to use clojure for scientific data analysis but I keep >

Re: math utilities question

2010-12-06 Thread Saul Hazledine
On Dec 6, 12:27 am, Robert McIntyre wrote: > I'm trying to use clojure for scientific data analysis but I keep > running into lacunas of functionality. > > 6. symbolic manipulation as in sage This is something that would be awesome to have in Clojure because, unlike most non-lisps, you can compil

Re: math utilities question

2010-12-06 Thread Ken Wesson
On Mon, Dec 6, 2010 at 2:59 AM, Benny Tsai wrote: > Always nice to see a fellow Neal Stephenson fan! > > On Dec 5, 10:26 pm, Ken Wesson wrote: >> On Mon, Dec 6, 2010 at 12:14 AM, Miki wrote: >> > Have you looked at Incanter? (http://incanter.org/) >> >> Hmm, interesting. Is there a Rhetor too?

Re: math utilities question

2010-12-05 Thread Benny Tsai
Always nice to see a fellow Neal Stephenson fan! On Dec 5, 10:26 pm, Ken Wesson wrote: > On Mon, Dec 6, 2010 at 12:14 AM, Miki wrote: > > Have you looked at Incanter? (http://incanter.org/) > > Hmm, interesting. Is there a Rhetor too? -- You received this message because you are subscribed to

Re: math utilities question

2010-12-05 Thread Ken Wesson
On Mon, Dec 6, 2010 at 12:14 AM, Miki wrote: > Have you looked at Incanter? (http://incanter.org/) Hmm, interesting. Is there a Rhetor too? -- 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

Re: math utilities question

2010-12-05 Thread Miki
Have you looked at Incanter? (http://incanter.org/) On Dec 5, 3:27 pm, Robert McIntyre wrote: > I'm trying to use clojure for scientific data analysis but I keep > running into lacunas of functionality. > > I'd love to hear the community's recommendations and experiences with this: > > Is there a

Re: math utilities question

2010-12-05 Thread Robert McIntyre
Thanks for your input --- I'm hoping that some of this stuff is already written with performance optimizations and the like. I'm wondering if people have had experience with java libraries of that sort and might have some recommendations. Anyone use clojure for scientific data analysis? What do y

Re: math utilities question

2010-12-05 Thread Ken Wesson
On Sun, Dec 5, 2010 at 6:27 PM, Robert McIntyre wrote: > I'm trying to use clojure for scientific data analysis but I keep > running into lacunas of functionality. > > I'd love to hear the community's recommendations and experiences with this: > > Is there a standard way to do things like: > 1. ta

Re: *math-context*

2009-07-10 Thread Rich Hickey
On Jul 10, 9:44 am, John Harrop wrote: > On Fri, Jul 10, 2009 at 9:22 AM, Rich Hickey wrote: > > On Jul 10, 9:01 am, Chouser wrote: > > > On Fri, Jul 10, 2009 at 7:14 AM, John Harrop > > wrote: > > > > It would be useful to have a *math-context* or similar that had a > > sensible > > > > defa

Re: *math-context*

2009-07-10 Thread John Harrop
On Fri, Jul 10, 2009 at 9:22 AM, Rich Hickey wrote: > On Jul 10, 9:01 am, Chouser wrote: > > On Fri, Jul 10, 2009 at 7:14 AM, John Harrop > wrote: > > > It would be useful to have a *math-context* or similar that had a > sensible > > > default and could be set with binding to affect bigdec calcu

Re: *math-context*

2009-07-10 Thread Rich Hickey
On Jul 10, 9:01 am, Chouser wrote: > On Fri, Jul 10, 2009 at 7:14 AM, John Harrop wrote: > > It would be useful to have a *math-context* or similar that had a sensible > > default and could be set with binding to affect bigdec calculations within > > the temporal scope of said binding. > > user

Re: *math-context*

2009-07-10 Thread Chouser
On Fri, Jul 10, 2009 at 7:14 AM, John Harrop wrote: > It would be useful to have a *math-context* or similar that had a sensible > default and could be set with binding to affect bigdec calculations within > the temporal scope of said binding. user=> (binding [*math-context* (java.math.MathContex

Re: Math functions

2009-01-05 Thread Stuart Sierra
On Jan 3, 2:48 pm, "Mark Engelberg" wrote: > I've noticed that Clojure is missing several math functions that come > standard with most programming languages, especially other > Schemes/Lisps.  Many of these functions are available in java's math > library, but only for doubles. Nice work, Mark.

Re: Math functions

2009-01-05 Thread Mark H.
On Jan 3, 7:46 pm, vogelrn wrote: > sqrt(a/b) should always be equal to sqrt(a)/sqrt(b) since (a/b)^m = > a^m/b^m for b != 0.  However, I'm unsure of whether it's the best > option for ratios because unless both the numerator and the > denominator are perfect squares, you're going to end up with

Re: Math functions

2009-01-04 Thread vogelrn
sqrt(a/b) should always be equal to sqrt(a)/sqrt(b) since (a/b)^m = a^m/b^m for b != 0. However, I'm unsure of whether it's the best option for ratios because unless both the numerator and the denominator are perfect squares, you're going to end up with a float anyway. This is trading an extra s

Re: Math functions

2009-01-03 Thread Mark Engelberg
On Sat, Jan 3, 2009 at 7:06 PM, Mark H. wrote: > Would you > find a sqrt that returns complex numbers for negative inputs (it would > be the appropriate branch of the sqrt function in order to make it > single-valued) useful? Ideally I'd also like that, but since complex numbers aren't part of

Re: Math functions

2009-01-03 Thread Mark H.
On Jan 3, 11:48 am, "Mark Engelberg" wrote: > If you give it an exact number (i.e., not a floating point), Floating-point numbers are exact -- it's their operations that may not be. *ducks* Seriously, handy code -- many thanks! I should check with someone whether sqrt(a/b) -> sqrt(a)/sqrt(b)

Re: Math as multimethods

2008-12-08 Thread ppierre
On 8 déc, 23:13, "Michael Reid" <[EMAIL PROTECTED]> wrote: > Then I of course write the implementations for various different > types. Then, because the multi-method names don't look nice, I wrote a > macro which transformed the regular operators into calls on the > multi-methods, i.e.: > >  (macr

Re: Math as multimethods

2008-12-08 Thread Michael Reid
I've been toying with something similar. The approach I took was to define multi-methods for the various operators: (defmulti add class) (defmulti sub class) (defmulti mul class) (defmulti div class) ... Then I of course write the implementations for various different types. Then, because the m

Re: Math as multimethods

2008-12-08 Thread ppierre
On 8 déc, 17:14, Mark Fredrickson <[EMAIL PROTECTED]> wrote: > >> Alternatively, could I provide a "multi- > >> math" lib to redefine the core math functions? > > > Type classes would be king. > > Do you mean this in the Haskell sense? Yes : http://www.haskell.org/tutorial/classes.html Haskell ma

Re: Math as multimethods

2008-12-08 Thread Mark Fredrickson
> >> Alternatively, could I provide a "multi- >> math" lib to redefine the core math functions? > > Type classes would be king. Do you mean this in the Haskell sense? (I'm not too familiar with those) Or something more like Java's types? I was thinking about how to solve this problem more gen

Re: Math as multimethods

2008-12-06 Thread ppierre
On 6 déc, 05:09, Mark Fredrickson <[EMAIL PROTECTED]> wrote: > Alternatively, could I provide a "multi- > math" lib to redefine the core math functions? Type classes would be king. But at least you can use your definition : (ns test.test (:refer-clojure :exclude [+ -])) (defn + [a b] 33