-
Notifications
You must be signed in to change notification settings - Fork 69
Added the (..) function as an alias to range. #14
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
Conversation
I'm new to PureScript so I apologize if this function appears somewhere else in the standard library and I have simply missed it. I've been programming primarily in Ruby for several years now and this is the notation that Ruby uses for creating a |
I suppose the only downside of adding this is it would mean having to change the book to use I'll let @paf31 weigh in though. :) |
@garyb Thank you for the feedback. That's a very good point, which I hadn't thought of at first. But after reading your comment I went back to the book and discovered that it does something very similar with the import Data.Array (null)
import Data.Array.Unsafe (tail)
length :: forall a. [a] -> Number
length arr =
if null arr
then 0
else 1 + length (tail arr) This has the same signature as |
I think this would be useful. I'd just need to change the wording in the book a bit. I'll be doing a release of the book later today, so it's no big deal. Thanks! |
@@ -287,6 +288,9 @@ foreign import range | |||
\ };\ | |||
\}" :: Number -> Number -> [Number] | |||
|
|||
(..) :: Number -> Number -> [Number] | |||
(..) = Data.Array.range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just say (..) = range
since we're in the same module.
I've updated the function definition based on the suggestion from @paf31. |
Added the (..) function as an alias to range.
Thanks! 👍 |
Page 38 of the Leanpub book (version published on 2014-08-16) defines a
(..)
function that is an alias forrange
. The book then uses this function repeatedly in following examples. This PR adds this function to theData.Array
library.