A workaround for integer types is totally trivial:
(defn my-numerator [x]
(if (ratio? x)
(numerator x)
x)
)
(defn my-denominator [x]
(if (ratio? x)
(denominator x)
1)
)
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post
I've been trying to refactor the - and - forms to use a common macro
form.
Ended up with this.
(defmacro threading [a b x forms]
(loop [x x
forms forms]
(if forms
(let [form (first forms)
f (first form)
r (rest form)
threaded (if (seq?
On Fri, Aug 28, 2015 at 12:37 PM, Akhil Wali green.transis...@gmail.com wrote:
This does work, but it's a bit of whammy.
Anyone with suggestions for improvement?
It doesn't appear to work for simple cases (where the expressions
aren't function calls w/ additional arguments), e.g. (- 1 inc)
It doesn't appear to work for simple cases (where the expressions
aren't function calls w/ additional arguments), e.g. (- 1 inc)
Thanks for that one. How silly of me :P
Here's a better version of threading.
(defmacro threading [a b x forms]
(loop [x x
forms forms]
(if forms
On Fri, Aug 28, 2015 at 5:33 PM, Atamert Ölçgen mu...@muhuk.com wrote:
Also, you know about as-, don't you?
Well, I'm aware of all other threading forms like some-, as-, etc.
This is just something I'm trying with - and -, and thought I'd discuss.
Perhaps the definition of as- can be used
Good one!
On Fri, Aug 28, 2015 at 6:34 PM, Moe Aboulkheir m...@nervous.io wrote:
The function is actually shorter without cond-: (conj (if first? args
(vec args)) x)
--
Akhil Wali
# https://github.com/darth10
# https://darth10.github.io
--
You received this message because you are
The function is actually shorter without cond-: (conj (if first? args (vec
args)) x)
Take care,
Moe
On Fri, Aug 28, 2015 at 1:59 PM, Akhil Wali green.transis...@gmail.com
wrote:
That's pretty neat!
But then - will be implemented using cond-, which is slightly off.
On Friday, August 28, 2015
Hi,
threading doesn't need to be a macro. In fact it would be easier to test if
it's just a function.
Also, you know about as-, don't you?
On Fri, Aug 28, 2015 at 2:37 PM, Akhil Wali green.transis...@gmail.com
wrote:
I've been trying to refactor the - and - forms to use a common macro
form.
On Fri, Aug 28, 2015 at 12:37 PM, Akhil Wali green.transis...@gmail.com
wrote:
This does work, but it's a bit of whammy.
Anyone with suggestions for improvement?
I went over this quickly, though it seems to work OK:
(defn threading [x first? forms]
(reduce
(fn [x form]
(if (seq?
That's pretty neat!
But then - will be implemented using cond-, which is slightly off.
On Friday, August 28, 2015 at 6:07:46 PM UTC+5:30, Moe Aboulkheir wrote:
On Fri, Aug 28, 2015 at 12:37 PM, Akhil Wali green.tr...@gmail.com
javascript: wrote:
This does work, but it's a bit of whammy.
I'm pretty new to Clojure, so please bear with me if this is obvious for
some reason. Maybe the answer is out there and I've been looking in the
wrong place.
I'm seeing some strange behavior losing type information when using eval in
certain circumstances. Here is an example:
Eval-ing a
Happy to announce the long-delayed release of Yagni 0.1.4!
This release includes the following major changes:
* Fixed a ClassNotFound exception when Yagni encountered a function with a
name like a class constructor (e.g. `-Something`)
* Removed the log4j dependency entirely.
* Cleaned up
A link to the project page might not have been a bad
idea: https://github.com/venantius/yagni
On Friday, August 28, 2015 at 9:59:25 AM UTC-7, W. David Jarvis wrote:
Happy to announce the long-delayed release of Yagni 0.1.4!
This release includes the following major changes:
* Fixed a
The parameter order of as- makes it convenient to use *inside *- so you
can name the threaded parameter only where it needs naming:
(- UFOT
(reverse)
(- (apply str))
(string/lower-case)
(as- x (string/replace slip on a tofu x banana peel)))
On Friday, August 28, 2015 at
On Fri, Aug 28, 2015 at 11:51 PM, Alan Thompson clooj...@gmail.com wrote:
I have become very partial to a simple adaptation of as- from the Tupelo
Core https://github.com/cloojure/tupelo library. I almost always like
to be explicit about the location the previous value, since either - or
-
I have become very partial to a simple adaptation of as- from the Tupelo
Core https://github.com/cloojure/tupelo library. I almost always like to
be explicit about the location the previous value, since either - or -
can sometimes be difficult if the threading forms don't always want the arg
as
Specter https://github.com/nathanmarz/specter is a library for querying
and updating data structures. For most things, I prefer it to zippers
or hand-written descent functions. Specter's approach is similar to
lenses, but I find it easier to understand and more featureful.
When starting out,
17 matches
Mail list logo