why on earth is this a macro and not a regular fn?

Jim

On 14/08/13 16:19, Daniel Meneses wrote:
Hi!

Thanks for your answer Sean I got it solved using clj-time

Also I found the problem with my macro attempt

user> (defmacro is
        [s instant]
        `(= (.get ~instant Calendar/DAY_OF_WEEK)
            (. Calendar ~s)))
#'current-day.core/is
user> (is FRIDAY (Calendar/getInstance))
false
user> (is WEDNESDAY (Calendar/getInstance))
true

I was quoting the symbol !!

On Tuesday, August 13, 2013 8:21:39 PM UTC-4, Sean Corfield wrote:

    Perhaps clj-time might help you?

    https://github.com/clj-time/clj-time
    <https://github.com/clj-time/clj-time>

    (ns time.core
      (:require [clj-time.core :as time]
                [clj-time.local :as local]
                [clj-time.predicates :as p]))

    (p/monday? (time/now)) ;; false
    (p/tuesday? (time/now)) ;; false
    (p/wednesday? (time/now)) ;; true (for me in California since
    (time/now) is UTC)

    (p/monday? (local/local-now)) ;; false
    (p/tuesday? (local/local-now)) ;; true (for me)
    (p/wednesday? (local/local-now)) ;; false (not yet in California)

    Sean

    On Tue, Aug 13, 2013 at 3:14 PM, Daniel Meneses Báez
    <dap...@gmail.com <javascript:>> wrote:
    > Hi :)
    >
    > I really want to know if there is a way to do this:
    >
    > (ns ...
    >    (:import [java.util Calendar]))
    >
    > (defsomething ;; if it is possible using a macro I'm ok with that
    >    calendar-member
    >    [member]
    >     (symbol (str "Calendar/" member)))
    >
    > what I want to know if an instance of Calendar "isMonday",
    "isFriday"
    > "isSunday" etc...
    >
    > so I was thinking to write something like
    >
    > (defn- isss [day instant]
    >     (= (.get instant Calendar/DATE) (calendar-member day)))
    >
    > and then use it like (def is-friday (partial isss 'FRIDAY)) ;;
    >
    > am I being to crazy?
    >
    > btw I'm really loving the language.
    >
    >
    >
    > --
    > Daniel Meneses Báez
    >
    > --
    > --
    > You received this message because you are subscribed to the Google
    > Groups "Clojure" group.
    > To post to this group, send email to clo...@googlegroups.com
    <javascript:>
    > Note that posts from new members are moderated - please be
    patient with your
    > first post.
    > To unsubscribe from this group, send email to
    > clojure+u...@googlegroups.com <javascript:>
    > For more options, visit this group at
    > http://groups.google.com/group/clojure?hl=en
    <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+u...@googlegroups.com <javascript:>.
    > For more options, visit https://groups.google.com/groups/opt_out
    <https://groups.google.com/groups/opt_out>.
    >
    >



-- Sean A Corfield -- (904) 302-SEAN
    An Architect's View -- http://corfield.org/
    World Singles, LLC. -- http://worldsingles.com/

    "Perfection is the enemy of the good."
    -- Gustave Flaubert, French realist novelist (1821-1880)

--
--
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/groups/opt_out.



--
--
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/groups/opt_out.


Reply via email to