Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isEven and isOdd to Basics #367

Closed
sindikat opened this issue Aug 24, 2015 · 9 comments
Closed

Add isEven and isOdd to Basics #367

sindikat opened this issue Aug 24, 2015 · 9 comments

Comments

@sindikat
Copy link

isEven is referenced on Basics docs, although the function is undefined. Both functions are used quite often, and they are tiny, so there's no trouble in adding them to Basics. Yes, the user can write (\x -> x%2==0), but isEven has little chance of name collision, used often and wouldn't require the user to write yet another small helper function.

@evancz
Copy link
Member

evancz commented Aug 24, 2015

This is the policy on adding new stuff to core. I don't really believe the assertion that "Both functions are used quite often". To push this a bit further, can you come up with a list of languages and whether they have this? Like, for Python, Java, JavaScript, Ruby, OCaml, SML, Clojure, Scala, etc. do they have this imported by default? Or something else? If so, what is it?

@evancz evancz closed this as completed Aug 24, 2015
@sindikat
Copy link
Author

FWIW, Clojure, Racket, Common Lisp and Emacs Lisp do import this or similar functions by default. I created this thread, because from meta-issue on API changes I understood I should create a new issue for any proposal for core that is somewhat viable. Other than that, I'm pretty happy to use *-extra packages.

@evancz
Copy link
Member

evancz commented Aug 24, 2015

What about the other languages I asked about? So far sounds like a lisp thing.

@maurisvh
Copy link

maurisvh commented Sep 5, 2015

FWIW, I'm writing a little Arithmetic library with things like this in it, based loosely on Haskell's prelude + arithmoi. That sounds like a better place for things like this. (Is Arithmetic a good name, though?)

@evancz
Copy link
Member

evancz commented Sep 7, 2015

Yeah, that's the right way to go for now. Arithmetic sounds like a nice name to me :)

@sindikat
Copy link
Author

sindikat commented Sep 7, 2015

👍 for having isEven and isOdd in Arithmetic. Also, there is a package math in Racket, which is very advanced and has all kinds of functions. If Arithmetic aspires to be anything like a general math-related library, it should be called math, I think.

@maurisvh
Copy link

To me, Math sounds like sin, cos, exp, ln... and Arithmetic sounds like isEven, isOdd, primes, gcd, lcm, Euclidean division... i.e., analysis vs. number theory. For some reason I feel like grouping them together would be messy, but maybe there's no reason not to?

(Also, some stuff got in the way, but I will continue work on the package soon. I'm basically translating arithmoi functions from Haskell to Elm to the best of my ability, which means it's quite involved, especially the prime stuff, but everything should be pretty fast!)

@sindikat
Copy link
Author

Just like there's Html, Html.Events, Html.Attributes, maybe there should be Math.Arithmetic, Math.Number (for number theory), Math.Trigonometry? Anyway, thanks for working on that :)

@lynn
Copy link

lynn commented Mar 14, 2016

I wrote elm-arithmetic, which includes isEven and isOdd, among a bunch of other useful functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants