This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-09
Channels
- # announcements (4)
- # beginners (71)
- # boot (258)
- # braid-chat (7)
- # business (3)
- # cider (5)
- # cljs-dev (5)
- # cljsrn (64)
- # clojure (154)
- # clojure-canada (1)
- # clojure-poland (112)
- # clojure-russia (290)
- # clojurebridge (1)
- # clojurescript (60)
- # community-development (1)
- # core-async (25)
- # cursive (9)
- # data-science (1)
- # datomic (40)
- # editors (14)
- # events (2)
- # hoplon (2)
- # jobs (3)
- # ldnclj (51)
- # lein-figwheel (2)
- # luminus (1)
- # off-topic (5)
- # om (57)
- # onyx (29)
- # overtone (1)
- # parinfer (52)
- # portland-or (1)
- # proton (17)
- # quil (2)
- # re-frame (77)
- # reagent (1)
- # ring-swagger (20)
- # spacemacs (1)
- # test-check (4)
- # testing (13)
- # yada (1)
If I pick up a book circa 2012, am I missing out a lot or possibly learning a lot of bad and outdated things?
Depends on the book...
There certainly has been quite a lot of movement in the ecosystem since then...
It’s likely that books targets Clojure 1.3 or maybe 1.4 so you can see what’s been added since here https://github.com/clojure/clojure/blob/master/changes.md @kamuela
(compojure/POST "/:foo" [x y & z :as request]
(println "testing 1 12 3")
(def yo request)
(str "x-> " x "\ny-> " y "\nz-> " z "\nrequest-map:\n" request))
how come this post request works fine, but
(compojure/POST "/:foo" request
(let [[x y & z] request]
(println "testing 1 12 3")
(def yo request)
(str "x-> " x "\ny-> " y "\nz-> " z "\nrequest-map:\n" request)))
this one doesn’t?and I get this error
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /arg. Reason:
<pre> nth not supported on this type: PersistentHashMap</pre></p>
@tmtwd: I'm having a hard time seeing a difference between those two code fragments... did you mean to post two different things?
(compojure/POST "/:foo" request
(let [[x y & z] request]
(println "testing 1 12 3")
(def yo request)
(str "x-> " x "\ny-> " y "\nz-> " z "\nrequest-map:\n" request)))
It's because compojure treats vectors differently: https://github.com/weavejester/compojure/wiki/Destructuring-Syntax#compojure-specific-destructuring
It's a macro, so normal Clojure destructuring doesn't apply directly.
(I didn't know, I had to go look it up)
(if (t/before? (t/now) (f/parse iso-8601 starts_at))
"Match scheduled"
(if (t/before? (f/parse iso-8601 ends_at) (t/now)) "Match is over" "Match is in progress”))
any ideas why this incorrect ?nesting of if
s is not good idea i guess, but the problem is in weird behaviour
also ends_at
and starts_at
are valid dates
> how to execute more than one form
what do you mean? ain’t forms evaluated recursively?
like (3rd(2nd(1st)))
(that's nesting)
well, but the order is correct?
can you give some examples where it doesn't work as expected?
just plugging in values seems to work for me
hmmmm
i exchange before?
to after?
in first if
and get either a string or empty in logger
seems like a really weird behavior, becaiuse i expect a least false
and evaluation of next if (which should return string too)
i for now ended up with (if (t/before? (t/now) (f/parse iso-8601 starts_at)) "Match scheduled" "Match is over”)
— but this doesn’t cover my case
and i want to get to the bottom of it
to gain deeper understanding of how things work in clojure
that doesn't make any sense
(if true (print "a") (if true (print "b") (print "c"))) ;; prints a
(if false (print "a") (if true (print "b") (print "c"))) ;; prints b
(if false (print "a") (if false (print "b") (print "c"))) ;; prints c
that's as basic as it gets
yep, sec
if you print the values you'r comparing (after parsing), are they the same type as t/now
?
they are #object[org.joda.time.DateTime 0x1fbd558d "2016-02-07T15:30:00.000Z”]
about else
— are there even at all else in clojure?
i can’t find reference
(if (t/before? (t/now) (f/parse iso-8601 starts_at)) "Match scheduled" "Match is over”)
this works as expected
yep, this is how i understand it (and appreciate 😅 )
this returns nothing to logger
(if (t/before? (t/now) (f/parse iso-8601 starts_at)) "Match scheduled"
((t/after? (t/now) (f/parse iso-8601 ends_at)) "Match is in progress"
"Match is over”))
:thinking_face:
you have an extra wrapping paren?
on the second line
or is that a missing if
yea you forgot the if
yes thank you
but surprisingly
result is the same
so i got and empy res with this too
(if (t/before? (t/now) (f/parse iso-8601 starts_at)) "Match scheduled"
(if (t/after? (t/now) (f/parse iso-8601 ends_at)) "Match is in progress"
"Match is over”))
mystery.
Empty result? You’re getting nil
when you run that code? I don’t see how that’s possible because all paths return a string.
yea...
are you writing this stuff directly into a repl as is, with preset values?
and making sure that each inner expression evaluates as you expect it would?
thank you, i’ll try this in repl (probably should do it all of the time before asking)
@olegakbarov, always ask if you want. There’s no judgement here. I’m pretty good at Clojure and I hang out here because I help when I can and I end up learning a lot too. It’s a good thing.