Re: [jobs] for newbie in europe
I live in Poznań (Poland). On Sunday, July 20, 2014 5:35:19 PM UTC+2, Aaron France wrote: > > Where are you based? > > > On Sun, Jul 20, 2014 at 4:29 PM, Krzysztof Władyka > wrote: > >> Hello, >> >> I am living in Poland and i have a little problem there... totally 0 jobs >> for Clojure Programmers. >> >> I am also beginner in Clojure. More about my IT skills you can read on >> site http://wladyka.eu/ . >> >> Do you know any option to get a job in Europe or remotely if i don't have >> any seriously experience with Clojure? But i see it's good and i want use >> that more then others languages. I can start with less salary but in my >> area is big trouble to find any job with Clojure... >> >> If you know somebody who need fresh blood tell him about me :) >> >> Best regards, >> Krzysztof Władyka >> >> -- >> 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 >> >> 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 >> 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+u...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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/d/optout.
Re: [jobs] for newbie in europe
Hi, We're primarily an Erlang shop but we have small applications in Clojure. Would you like to have a chat with my manager about positions available here? On Mon, Jul 21, 2014 at 10:13 AM, Krzysztof Władyka wrote: > I live in Poznań (Poland). > > > On Sunday, July 20, 2014 5:35:19 PM UTC+2, Aaron France wrote: > >> Where are you based? >> >> >> On Sun, Jul 20, 2014 at 4:29 PM, Krzysztof Władyka >> wrote: >> >>> Hello, >>> >>> I am living in Poland and i have a little problem there... totally 0 >>> jobs for Clojure Programmers. >>> >>> I am also beginner in Clojure. More about my IT skills you can read on >>> site http://wladyka.eu/ . >>> >>> Do you know any option to get a job in Europe or remotely if i don't >>> have any seriously experience with Clojure? But i see it's good and i want >>> use that more then others languages. I can start with less salary but in my >>> area is big trouble to find any job with Clojure... >>> >>> If you know somebody who need fresh blood tell him about me :) >>> >>> Best regards, >>> Krzysztof Władyka >>> >>> -- >>> 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 >>> >>> 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 >>> >>> 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+u...@googlegroups.com. >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > 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/d/optout. > -- 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/d/optout.
clojure.stacktrace/root-cause VS clojure.repl/root-cause, are they redundant?
Hi, I'm learning about tools to help me debug from the REPL, and I found these two with the same name: clojure.stacktrace/root-cause clojure.repl/root-cause For a very simple case (wrong arity), they give pretty similar output: user=> (char 0 0 0) CompilerException clojure.lang.ArityException: Wrong number of args (3) passed to: core/char--inliner, compiling:(/tmp/form-init6819528724684564936.clj:1:1) user=> (clojure.stacktrace/root-cause *e) # user=> (clojure.repl/root-cause *e) # I looked at the source code and they look fairly similar, but I didn't understand the exact details. If they do the same job, then which one does it best? If they perform different roles, then could you describe the difference to a user who doesn't need to understand the internals? ( I'm happy to understand them if you are willing to explain, though :) ) -- 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/d/optout.
Re: positional + keyword args
Hi, If I understand your pb correctly, and form what I have seen in the Scala world, there is maybe a simpler way to do it : (defn process-args [args fnkeys fndefault] (let [[positional-args named-args] (split-with (complement keyword?) args) named-args (into {} (map vec (partition 2 named-args)))] (merge fndefault (zipmap fnkeys positional-args) named-args))) (defn f [& args] (process-args args [:a :b :c] {:a 1 :c 2})) (f "40" "abc" :b "abc2" :bb "ahoy") ;=> {:bb "ahoy", :b "abc2", :a "40", :c 2} Jon On Mon, Jul 21, 2014 at 3:34 AM, Sam Raker wrote: > OK! After a few false starts, I think I got it: > > (defn f [& args] (let [args (vec args) default-args-atom (atom {:a 1 :b 2 > :c 3 :d 4}) kwds [:a :b :c :d]] > (do > (dorun (map-indexed (fn [idx arg] (if > (keyword? arg) > > (swap! default-args-atom assoc arg (get args (inc idx))) > > (if (not (keyword? (get args (dec idx (swap! default-args-atom > assoc (get kwds idx) arg > args)) > (the-real-func (:a @default-args-atom) (:b > @default-args-atom) (:c @default-args-atom) (:d @default-args-atom) > > I feel like I should turn this into a macro, but I've spent enough time on > it as is, for now. > > On Sunday, July 20, 2014 8:16:55 PM UTC-4, Alex Baranosky wrote: > >> You can get keyword args like this: >> >> (defn f [& {:keys [a b c d] >> :or {a 1 b 2 c 3 d 4}}] >> [a b c d]) >> >> But you cannot also get the ability to call: >> (f 5 6 7 8) >> >> >> On Sun, Jul 20, 2014 at 4:13 PM, Sam Raker wrote: >> >>> I'm trying to write a function that takes (up to) 4 arguments. I want to >>> be able to supply every argument positionally, with a keyword or as a >>> default, so that >>> >>> (f) >>> (f 1) >>> (f 1 2) >>> (f 1 2 3) >>> (f 1 2 3 4) >>> (f 1 :b 2) >>> (f 1 2 :c 3) >>> ... >>> (f :a 1 :b 2 :c 3 :d 4) >>> >>> are all equivalent. In Python, I could do this by >>> >>> def f(a=1,b=2,c=3,d=4):... >>> >>> but I'm not sure how to do it in Clojure. >>> >>> -- >>> 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 >>> >>> 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 >>> >>> 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+u...@googlegroups.com. >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > 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/d/optout. > -- 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/d/optout.
Re: clojure.stacktrace/root-cause VS clojure.repl/root-cause, are they redundant?
I have now noticed that these two are also very similar: clojure.stacktrace/print-stack-trace clojure.repl/pst; (for Print Stack Trace) Here is their output for the same error: user=> (char 0 0 0) CompilerException clojure.lang.ArityException: Wrong number of args (3) passed to: core/char--inliner, compiling:(/tmp/form-init9068522213039312274.clj:1:1) user=> (clojure.stacktrace/print-stack-trace *e) clojure.lang.Compiler$CompilerException: clojure.lang.ArityException: Wrong number of args (3) passed to: core/char--inliner, compiling:(/tmp/form-init9068522213039312274.clj:1:1) at clojure.lang.Compiler.analyzeSeq (Compiler.java:6651) clojure.lang.Compiler.analyze (Compiler.java:6445) clojure.lang.Compiler.analyze (Compiler.java:6406) clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5782) clojure.lang.Compiler$FnMethod.parse (Compiler.java:5217) clojure.lang.Compiler$FnExpr.parse (Compiler.java:3846) clojure.lang.Compiler.analyzeSeq (Compiler.java:6642) clojure.lang.Compiler.analyze (Compiler.java:6445) clojure.lang.Compiler.eval (Compiler.java:6700) clojure.lang.Compiler.eval (Compiler.java:) clojure.core$eval.invoke (core.clj:2927) clojure.main$repl$read_eval_print__6625$fn__6628.invoke (main.clj:239) clojure.main$repl$read_eval_print__6625.invoke (main.clj:239) clojure.main$repl$fn__6634.invoke (main.clj:257) clojure.main$repl.doInvoke (main.clj:257) clojure.lang.RestFn.invoke (RestFn.java:1096) clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__591.invoke (interruptible_eval.clj:56) clojure.lang.AFn.applyToHelper (AFn.java:152) clojure.lang.AFn.applyTo (AFn.java:144) clojure.core$apply.invoke (core.clj:624) clojure.core$with_bindings_STAR_.doInvoke (core.clj:1862) clojure.lang.RestFn.invoke (RestFn.java:425) clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:41) clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__632$fn__635.invoke (interruptible_eval.clj:171) clojure.core$comp$fn__4192.invoke (core.clj:2402) clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__625.invoke (interruptible_eval.clj:138) clojure.lang.AFn.run (AFn.java:22) java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145) java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:615) java.lang.Thread.run (Thread.java:744) nil user=> (clojure.repl/pst *e) CompilerException clojure.lang.ArityException: Wrong number of args (3) passed to: core/char--inliner, compiling:(/tmp/form-init9068522213039312274.clj:1:1) clojure.lang.Compiler.analyzeSeq (Compiler.java:6651) clojure.lang.Compiler.analyze (Compiler.java:6445) clojure.lang.Compiler.analyze (Compiler.java:6406) clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5782) clojure.lang.Compiler$FnMethod.parse (Compiler.java:5217) clojure.lang.Compiler$FnExpr.parse (Compiler.java:3846) clojure.lang.Compiler.analyzeSeq (Compiler.java:6642) clojure.lang.Compiler.analyze (Compiler.java:6445) clojure.lang.Compiler.eval (Compiler.java:6700) clojure.lang.Compiler.eval (Compiler.java:) clojure.core/eval (core.clj:2927) clojure.main/repl/read-eval-print--6625/fn--6628 (main.clj:239) Caused by: ArityException Wrong number of args (3) passed to: core/char--inliner clojure.lang.Compiler.analyzeSeq (Compiler.java:6639) clojure.lang.Compiler.analyze (Compiler.java:6445) clojure.lang.Compiler.analyze (Compiler.java:6406) clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5782) clojure.lang.Compiler$FnMethod.parse (Compiler.java:5217) clojure.lang.Compiler$FnExpr.parse (Compiler.java:3846) nil The top part of their output is the same, but not the bottom. If no-one comes up with an explanation, I'll use both until I understand which one is more useful to me, and report back here if I remember (hopefully!) On Monday, 21 July 2014 12:30:17 UTC+1, Pierre Masci wrote: > > Hi, I'm learning about tools to help me debug from the REPL, and I found > these two with the same name: > > clojure.stacktrace/root-cause > > clojure.repl/root-cause > > For a very simple case (wrong arity), they give pretty similar output: > > user=> (char 0 0 0) > CompilerException clojure.lang.ArityException: Wrong number of args > (3) passed to: core/char--inliner, > compiling:(/tmp/form-init6819528724684564936.clj:1:1) > > user=> (clojure.stacktrace/root-cause *e) > # passed to: core/char--inliner> > > user=> (clojure.repl/root-cause *e) > # (3) passed to: core/char--inliner, > compiling:(/tmp/form-init6819528724684564936.clj:1:1)> > > > I looked at the source code and they look fairly similar, but I didn't > understand the exact details. > > If they do
reload dependencies
Hi, Is there a better way to reload dependencies in Cider than by shutting down the nrepl and running 'lein deps'? Many Thanks Aidy -- 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/d/optout.
Re: reload dependencies
You don't need to run 'lein deps', simply cider-restart and they will be updated automatically. If you want to get really fancy and modify them at runtime, take a look at pomegranate: https://github.com/cemerick/pomegranate and the alembic project made for this use-case: https://github.com/pallet/alembic On Mon, Jul 21, 2014 at 11:28 AM, wrote: > Hi, > > Is there a better way to reload dependencies in Cider than by shutting > down the nrepl and running 'lein deps'? > > Many Thanks > > Aidy > > -- > 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/d/optout. > -- 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/d/optout.
Re: Scheduling state change?
> > Hi, > I gave this a try over the weekend and then I do this it all works fine: (import java.util.concurrent.ScheduledThreadPoolExecutor ) (import java.util.concurrent.TimeUnit) (def executor (ScheduledThreadPoolExecutor. 1)) (defn my-func [] (println "adsf" ) (.schedule executor my-func 1 TimeUnit/SECONDS)) That prints out the line once a second, every second. But when I change my function so that it takes arguments, like this: (defn my-func [id] (println id ) (.schedule executor (my-func (inc id)) 1 TimeUnit/SECONDS)) I get a stackoverflow and the print out happen immediately, they are not scheduled. This is also the behaviour I got with the at-at library. I'd rather use something like the latter as it stops me from having mutable state inside my functions. Any ideas? Thomas -- 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/d/optout.
A more general case of some->?
Hi, Recently I found myself wanting a macro similar to some-> or some->> but one where I could specify an arbitrary predicate instead of nil?. For example, I have a Ring request map which I wish to pass through a number of functions. Any of these functions might return an error response and if so I do not want to evaluate any remaining forms--much like how some-> will not evaluate after a nil response. To do this, I wrote a macro that is essentially some-> but which takes a predicate. Here's the macro I ended up with: (defmacro until-pred-> "Like some-> but evalutes via -> until or if a predicate is true." [pred expr & forms] (let [g (gensym) pstep (fn [step] `(if (~pred ~g) ~g (-> ~g ~step)))] `(let [~g ~expr ~@(interleave (repeat g) (map pstep forms))] ~g))) An example of how I might use this: (defn my-handler [request] (until-pred-> error-response? request check-auth check-balance ...)) That said, I'm wondering if there is a more idiomatic way of passing Ring request maps through a series of functions, each of which might be a terminal step? I'm also curious if there's a particular reason some-> wasn't implemented in a more general way; perhaps the fact that I can so easily write a macro that achieves this myself is a good enough reason? Thanks, Max -- 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/d/optout.
Re: Scheduling state change?
you want to pass a closure, not call my-func recursively: (defn my-func [id] (println id ) (.schedule executor #(my-func (inc id)) 1 TimeUnit/SECONDS)) or (defn my-func [id] (println id ) (.schedule executor (fn [_] (my-func (inc id))) 1 TimeUnit/SECONDS)) Luc P. > > > > > Hi, > > > > I gave this a try over the weekend and then I do this it all works fine: > > (import java.util.concurrent.ScheduledThreadPoolExecutor ) > (import java.util.concurrent.TimeUnit) > (def executor (ScheduledThreadPoolExecutor. 1)) > > (defn my-func [] > (println "adsf" ) > (.schedule executor my-func 1 TimeUnit/SECONDS)) > > That prints out the line once a second, every second. But when I change my > function so that it takes arguments, like this: > > (defn my-func [id] > (println id ) > (.schedule executor (my-func (inc id)) 1 TimeUnit/SECONDS)) > > I get a stackoverflow and the print out happen immediately, they are not > scheduled. This is also the behaviour I got with the at-at library. I'd > rather use something like the latter as it stops me from having mutable > state inside my functions. > > Any ideas? > > Thomas > > > > > > > -- > 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/d/optout. > -- Softaddicts sent by ibisMail from my ipad! -- 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/d/optout.
Re: Lessons Learned from Adopting Clojure
> (alt-enter mapped to "eval sexp in repl" is used heavily) That's interesting but it doesn't seem to be a default and I can't find anything like 'eval sexp in repl' in the keymap nor anywhere else (using the IDEA search functionality under Preferences (OSX)). On Thursday, February 6, 2014 3:06:15 PM UTC+1, Korny wrote: > > I've been doing something very similar, but using IntelliJ + Cursive > Clojure - run Midje autotest inside the IDE for running tests, and also for > manually evaluating snippets of code. > > Cursive gives me a lot of what I had from Emacs - paredit editing, > tight repl integration (alt-enter mapped to "eval sexp in repl" is used > heavily), decent code formatting and indentation. And also all the Gui > stuff I always found clunky in Emacs: graphical directory tree, tool tips & > autocomplete, graphical hints for things like git integration, code > navigation including Java code. I love emacs, but I'm increasingly > frustrated by the limitations of it's mostly-text interface > > (p.s. I saw Jay's talk at Yow, and it was excellent, though a bit > depressing - we had pain getting Clojure working at our client, but far > less than Jay did. When the Yow videos come out you can compare his > experiences with mine...) > > - Korny > > > On 5 February 2014 09:09, Colin Yates > > wrote: > >> Interesting - thanks all. >> >> My experience of Light Table is quite close to Norman's, although I >> discounted that *in my case* to not spending enough time with it. Knowing >> a little about who Sean is (from following your blog/comments/clojure.jdbc, >> not stalking! :)) I put a lot of weight behind his opinion. Brian's too, >> whose emacs's environment is similar to mine. I happen to run midge >> :autotest in a separate console rather than in emacs with xmonad as my >> desktop manager (I mention xmonad because if you haven't checked it out you >> should - you will love it or hate it). >> >> Guess I just need to carve out some time to play with it myself. >> >> On Wednesday, 5 February 2014 06:09:38 UTC, Sean Corfield wrote: >> >>> On Tue, Feb 4, 2014 at 6:07 PM, Brian Marick >>> wrote: >>> > I always grate at the need to then "immortalize" the core of what I >>> did in the REPL in repeatable tests. >>> >>> That's actually one of the things that bothered me in the Emacs REPL >>> world: working in the REPL was separate from working in my production >>> source and my test source. It's one of the things that has me really >>> hooked on LightTable. I have my source and test namespaces both open. >>> I have them both connected to a "REPL". I can evaluate any code, in >>> place, in either file. If I grow some code in the source file, I can >>> put (defn some-name [args]) in front of it and M-) slurps it into a >>> function - done! If I grow some code in the test file, I can put >>> (expect result-value) in front of it and M-) slurps it into a test - >>> done! >>> >>> Since I moved to LightTable, I've found myself doing even more >>> REPL-Driven-Development than before because it's so much easier to >>> turn the experiments into code - or tests - in place. >>> -- >>> 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 clo...@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+u...@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+u...@googlegroups.com . >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > Kornelis Sietsma korny at my surname dot com http://korny.info > .fnord { display: none !important; } > -- 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/d/optout.
ANN clj-duration: reader literal for durations
Hi, I created this little library that adds first-level support for durations via a tagged literal: #unit/duration "2D 10h 5m 10s" This creates a java.time.Duration with a value of 2 days 10 hours 5 minutes and 10 seconds. It also makes it easy to quickly turn some huge milliseconds amount into something human digestible: (duration-of-millis 1234567) ; => #unit/duration "20m 34s 567ms" I found this really useful when scheduling periodic background tasks, specifying timeouts, measuring the runtime of some code or anyplace where you work with durations. You can find more on motivation and usage examples on GitHub: https://github.com/gerrit-hntschl/clj-duration Hope it is helpful to somebody in the community! Cheers, Gerrit -- 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/d/optout.
Re: Stumped: unable to resolve symbol in macro expansion
In my case, I'm trying to use a the expression '[x] that is available to the macro in the resulting product. So I don't want the value of x at all, just a vector with the symbol x. That vector is in a variable I have in the macro named 'positional-parameters', so I substitute '~positional-parameters to with the hope of getting '[x] in the resulting definition. Here's a fragment of the overall defs. As you can see I'm just messing around, I was trying to write a defun with 'supplied-p' lambda list semantics, and my clojure/macrology is awful. It's the macro near the bottom. You can append this to https://github.com/dtenny/clojdt/blob/master/src/jdt/cl.clj if you want to git clone and compile it. (def lambda-list-keyword-symbols "Symbols without namespace specifications" (into #{} (map symbol ["&allow-other-keys" "&key" "&rest" "&aux" "&optional"]))) (defn lambda-list-keyword? "If x is a lambda list keyword, in any case, return the canonicalized form as a symbol. If it starts with an ampersand but is not a valid lambda list keyword, throw an exception." [x] (let [sym-name (.toLowerCase (name x))] (if (= (first sym-name) \&) (if-let [lambda-sym (lambda-list-keyword-symbols (symbol sym-name))] lambda-sym (throw (Exception. (str "'" x "' is not a valid lambda list keyword." nil))) (defn lambda-list-segment "Return three values in a vector. The first value is a vector of non-lambda-list-keywords in l before the next lambda list keyword in the list. Order is preserved. The second value is the canonicalized lambda list keyword (as a clojure symbol, e.g. '&aux) that terminated accumulation, or nil if we reached the end of the list. The third value is the rest of the list following the lambda list keyword, or nil if there aren't any more values. E.g. (lambda-list-segment '(a b &optional c)) => [[a b] &optional (c)]" [l] (loop [result [] l l] (if (empty? l) [result nil nil] (let [head (first l) tail (rest l) lambda-keyword (lambda-list-keyword? head)] (if lambda-keyword [result lambda-keyword tail] (recur (conj result head) tail)) (defn partition-lambda-list "Return a map keyed by lambda list keyword (or the pseudo keyword '&positional' for positional args), and valued by a vector lambda vars associated with the type of lambda list element, in the order specified by the caller. E.g. (partition-lambda-list [a b c &optional (d nil d-supplied-p) &key e]) => {&positional [a b c] &optional [(d nil d-supplied-p)] &key [e]} Ignore case in things appearing to be lambda list keywords. Complain if any symbol begins with an ampersand and is not a valid lambda list keyword. Preserve order of parameters." [lambda-list] (let [first-chunk (lambda-list-segment lambda-list) positionals (first first-chunk)] (loop [result {'&positional positionals} next-lambda-key (second first-chunk) lambda-list (nth first-chunk 2)] (if (empty? lambda-list) (if next-lambda-key (merge result {next-lambda-key []}) ; in case it's &allow-other-keys result) (let [chunk (lambda-list-segment lambda-list)] (recur (merge result {next-lambda-key (first chunk)}) (second chunk) (nth chunk 2))) (defn parse-defun-decls "Parse defun elements following the lambda list. If there are declarations, strip them from the sequence. Return a vector of two things. 1) the docstring, or nil if there isn't one. 2) forms following the optional declarations and docstring, nil if there aren't any." [s] (let [declare? (fn [l] (and (list? l) (.equalsIgnoreCase (name (first l)) "declare")))] (loop [s s] (if (empty? s) [nil nil] (let [head (first s)] (cond (string? head) [head (rest s)] ; **BUG** won't work if declare is after docstring (declare? head) (recur (rest s)) :else [nil s])) (defn positional-values "Given a sequence of formal parameter names for positional values and a sequence of actual arguments to a defun'ed function call, return a vector of values from actual args to be bound to parameters. Return [] if there aren't any." [parameters actual-args] (if parameters (if (< (count actual-args) (count parameters)) (throw (Exception. (str "Insufficient arguments in " actual-args " to match positional parameters in " parameters))) (loop [values [] args actual-args] (if (empty? args) values (recur (conj values (first args)) (rest args) [])) ;; *FINISH*: define/support RETURN-FROM (defmacro defun "defun function-name lambda-list [[declaration* | documentation]] form* => function-name Arguments and Values: function-name--
Re: How to control evaluation of code with cider
> > As a work in progress, here is the code I came up with, it hard codes the > function name: > (defun cider-eval-cljs-defun-at-point (&optional prefix) "Evaluate the current toplevel form, and print result in the minibuffer. With a PREFIX argument, print the result in the current buffer." (interactive "P") (let ((form (concat "(user/live-repl-client \"" (replace-regexp-in-string (regexp-quote "\"") (regexp-quote "\\\"") (replace-regexp-in-string (regexp-quote "\\") (regexp-quote "") (cider-defun-at-point))) "\")"))) (if prefix (cider-interactive-eval-print form) (cider-interactive-eval form (define-key cider-mode-map (kbd "C-c C-v") 'cider-eval-cljs-defun-at-point) -- 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/d/optout.
Re: A more general case of some->?
The predicate parameter introduces an additional predicate check on a per-step basis which can be avoided under most circumstances. If check-auth or check-balance return just their input value where that is valid, threading has no use here. They could be modified to only return something if there is an error, otherwise nil. For clarity, they could then be called auth-error and balance-error. They could be composed with some-fn and be used in a handler to serve the error as early as possible. E. g. (def my-handler-error (some-fn auth-error balance-error)) (defn my-handler [request] (or (my-handler-error request) ;; serve response )) On Monday, July 21, 2014 6:20:50 PM UTC+2, Max Countryman wrote: > > Hi, > > Recently I found myself wanting a macro similar to some-> or some->> but > one where I could specify an arbitrary predicate instead of nil?. For > example, I have a Ring request map which I wish to pass through a number of > functions. Any of these functions might return an error response and if so > I do not want to evaluate any remaining forms—much like how some-> will not > evaluate after a nil response. To do this, I wrote a macro that is > essentially some-> but which takes a predicate. > > Here’s the macro I ended up with: > > (defmacro until-pred-> > "Like some-> but evalutes via -> until or if a predicate is true." > [pred expr & forms] > (let [g (gensym) > pstep (fn [step] > `(if (~pred ~g) >~g >(-> ~g ~step)))] > `(let [~g ~expr >~@(interleave (repeat g) (map pstep forms))] >~g))) > > An example of how I might use this: > > (defn my-handler > [request] > (until-pred-> error-response? request > check-auth > check-balance > …)) > > That said, I’m wondering if there is a more idiomatic way of passing Ring > request maps through a series of functions, each of which might be a > terminal step? I’m also curious if there’s a particular reason some-> > wasn’t implemented in a more general way; perhaps the fact that I can so > easily write a macro that achieves this myself is a good enough reason? > > Thanks, > > > Max -- 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/d/optout.
Re: Stumped: unable to resolve symbol in macro expansion
I haven't taken the time to fully grok your macro, but the error is not the fault of your macro, but of the function invocation. (foo x) is causing the error because x is undefined. foo is a plain function, not a macro, so it tries to evaluate each argument. (foo 'x) works fine for me, as does (let [x 42] (foo x)) I guess the fact that (foo x) recycled the name of the parameter used in the function definition is what made the error message confusing? On Monday, July 21, 2014 9:49:10 AM UTC-7, Dave Tenny wrote: > > In my case, I'm trying to use a the expression '[x] that is available to > the macro in the resulting product. So I don't want the value of x at all, > just a vector with the symbol x. > > That vector is in a variable I have in the macro named > 'positional-parameters', so I substitute '~positional-parameters to with > the hope of getting '[x] in the resulting definition. > > Here's a fragment of the overall defs. As you can see I'm just messing > around, I was trying to write a defun with 'supplied-p' lambda list > semantics, and my clojure/macrology is awful. It's the macro near the > bottom. You can append this to > https://github.com/dtenny/clojdt/blob/master/src/jdt/cl.clj if you want > to git clone and compile it. > > (def lambda-list-keyword-symbols > "Symbols without namespace specifications" > (into #{} (map symbol ["&allow-other-keys" "&key" "&rest" "&aux" > "&optional"]))) > > (defn lambda-list-keyword? > "If x is a lambda list keyword, in any case, return the canonicalized > form as a symbol. >If it starts with an ampersand but is not a valid lambda list keyword, > throw an exception." > [x] > (let [sym-name (.toLowerCase (name x))] > (if (= (first sym-name) \&) > (if-let [lambda-sym (lambda-list-keyword-symbols (symbol sym-name))] > lambda-sym > (throw (Exception. (str "'" x "' is not a valid lambda list > keyword." > nil))) > > (defn lambda-list-segment > "Return three values in a vector. > >The first value is a vector of non-lambda-list-keywords >in l before the next lambda list keyword in the list. Order is > preserved. > >The second value is the canonicalized lambda list keyword (as a clojure > symbol, e.g. '&aux) >that terminated accumulation, or nil if we reached the end of the list. > >The third value is the rest of the list following the lambda list > keyword, or nil if there aren't >any more values. > >E.g. (lambda-list-segment '(a b &optional c)) > => [[a b] &optional (c)]" > [l] > (loop [result [] l l] > (if (empty? l) > [result nil nil] > (let [head (first l) > tail (rest l) > lambda-keyword (lambda-list-keyword? head)] > (if lambda-keyword > [result lambda-keyword tail] > (recur (conj result head) tail)) > > (defn partition-lambda-list > "Return a map keyed by lambda list keyword (or the pseudo keyword > '&positional' >for positional args), and valued by a vector lambda vars associated > with the >type of lambda list element, in the order specified by the caller. >E.g. (partition-lambda-list [a b c &optional (d nil d-supplied-p) &key > e]) > => {&positional [a b c] &optional [(d nil d-supplied-p)] &key [e]} >Ignore case in things appearing to be lambda list keywords. >Complain if any symbol begins with an ampersand and is not a valid > lambda list keyword. >Preserve order of parameters." > [lambda-list] > (let [first-chunk (lambda-list-segment lambda-list) > positionals (first first-chunk)] > (loop [result {'&positional positionals} >next-lambda-key (second first-chunk) >lambda-list (nth first-chunk 2)] > (if (empty? lambda-list) > (if next-lambda-key > (merge result {next-lambda-key []}) ; in case it's > &allow-other-keys > result) > (let [chunk (lambda-list-segment lambda-list)] > (recur (merge result {next-lambda-key (first chunk)}) > (second chunk) > (nth chunk 2))) > > (defn parse-defun-decls > "Parse defun elements following the lambda list. >If there are declarations, strip them from the sequence. >Return a vector of two things. >1) the docstring, or nil if there isn't one. >2) forms following the optional declarations and docstring, nil if > there aren't any." > [s] > (let [declare? (fn [l] >(and (list? l) > (.equalsIgnoreCase (name (first l)) "declare")))] > (loop [s s] > (if (empty? s) > [nil nil] > (let [head (first s)] > (cond (string? head) [head (rest s)] ; **BUG** won't work if > declare is after docstring > (declare? head) (recur (rest s)) > :else [nil s])) > > (defn positional-values > "Given a sequence of formal parameter names for positional values >and
Re: A more general case of some->?
Check out pedestals interceptors, they handle both error and pause/resume-request functionality. Seems you could have great use of it. Pedestal-service is the repo. pedestal.io /Linus On Monday, July 21, 2014, Leon Grapenthin wrote: > The predicate parameter introduces an additional predicate check on a > per-step basis which can be avoided under most circumstances. > > If check-auth or check-balance return just their input value where that is > valid, threading has no use here. > > They could be modified to only return something if there is an error, > otherwise nil. For clarity, they could then be called auth-error and > balance-error. They could be composed with some-fn and be used in a handler > to serve the error as early as possible. > > E. g. > > (def my-handler-error (some-fn auth-error balance-error)) > > (defn my-handler > [request] > (or (my-handler-error request) > ;; serve response > )) > > > > On Monday, July 21, 2014 6:20:50 PM UTC+2, Max Countryman wrote: >> >> Hi, >> >> Recently I found myself wanting a macro similar to some-> or some->> but >> one where I could specify an arbitrary predicate instead of nil?. For >> example, I have a Ring request map which I wish to pass through a number of >> functions. Any of these functions might return an error response and if so >> I do not want to evaluate any remaining forms—much like how some-> will not >> evaluate after a nil response. To do this, I wrote a macro that is >> essentially some-> but which takes a predicate. >> >> Here’s the macro I ended up with: >> >> (defmacro until-pred-> >> "Like some-> but evalutes via -> until or if a predicate is true." >> [pred expr & forms] >> (let [g (gensym) >> pstep (fn [step] >> `(if (~pred ~g) >>~g >>(-> ~g ~step)))] >> `(let [~g ~expr >>~@(interleave (repeat g) (map pstep forms))] >>~g))) >> >> An example of how I might use this: >> >> (defn my-handler >> [request] >> (until-pred-> error-response? request >> check-auth >> check-balance >> …)) >> >> That said, I’m wondering if there is a more idiomatic way of passing Ring >> request maps through a series of functions, each of which might be a >> terminal step? I’m also curious if there’s a particular reason some-> >> wasn’t implemented in a more general way; perhaps the fact that I can so >> easily write a macro that achieves this myself is a good enough reason? >> >> Thanks, >> >> >> Max > > -- > 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/d/optout. > -- 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/d/optout.
Re: Lessons Learned from Adopting Clojure
Cursive doesn't come with default keybindings right now, due to the fact that IntelliJ's keybindings handling was a little unpredictable until recently. It's better since v13 so when I get some time I'll be sorting out a proper keymap. In the meantime, the commands you want are "Run form before cursor in REPL" or "Run top form in REPL", which are under the Tools menu. They won't be present in the actual menu until you have a REPL started, but you can find them there in the Keymap settings in order to add keybindings for them. On 21 July 2014 18:23, wrote: > > (alt-enter mapped to "eval sexp in repl" is used heavily) > > That's interesting but it doesn't seem to be a default and I can't find > anything like 'eval sexp in repl' in the keymap nor anywhere else (using > the IDEA search functionality under Preferences (OSX)). > > > On Thursday, February 6, 2014 3:06:15 PM UTC+1, Korny wrote: > >> I've been doing something very similar, but using IntelliJ + Cursive >> Clojure - run Midje autotest inside the IDE for running tests, and also for >> manually evaluating snippets of code. >> >> Cursive gives me a lot of what I had from Emacs - paredit editing, >> tight repl integration (alt-enter mapped to "eval sexp in repl" is used >> heavily), decent code formatting and indentation. And also all the Gui >> stuff I always found clunky in Emacs: graphical directory tree, tool tips & >> autocomplete, graphical hints for things like git integration, code >> navigation including Java code. I love emacs, but I'm increasingly >> frustrated by the limitations of it's mostly-text interface >> >> (p.s. I saw Jay's talk at Yow, and it was excellent, though a bit >> depressing - we had pain getting Clojure working at our client, but far >> less than Jay did. When the Yow videos come out you can compare his >> experiences with mine...) >> >> - Korny >> >> >> On 5 February 2014 09:09, Colin Yates wrote: >> >>> Interesting - thanks all. >>> >>> My experience of Light Table is quite close to Norman's, although I >>> discounted that *in my case* to not spending enough time with it. Knowing >>> a little about who Sean is (from following your blog/comments/clojure.jdbc, >>> not stalking! :)) I put a lot of weight behind his opinion. Brian's too, >>> whose emacs's environment is similar to mine. I happen to run midge >>> :autotest in a separate console rather than in emacs with xmonad as my >>> desktop manager (I mention xmonad because if you haven't checked it out you >>> should - you will love it or hate it). >>> >>> Guess I just need to carve out some time to play with it myself. >>> >>> On Wednesday, 5 February 2014 06:09:38 UTC, Sean Corfield wrote: >>> On Tue, Feb 4, 2014 at 6:07 PM, Brian Marick wrote: > I always grate at the need to then "immortalize" the core of what I did in the REPL in repeatable tests. That's actually one of the things that bothered me in the Emacs REPL world: working in the REPL was separate from working in my production source and my test source. It's one of the things that has me really hooked on LightTable. I have my source and test namespaces both open. I have them both connected to a "REPL". I can evaluate any code, in place, in either file. If I grow some code in the source file, I can put (defn some-name [args]) in front of it and M-) slurps it into a function - done! If I grow some code in the test file, I can put (expect result-value) in front of it and M-) slurps it into a test - done! Since I moved to LightTable, I've found myself doing even more REPL-Driven-Development than before because it's so much easier to turn the experiments into code - or tests - in place. -- 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 clo...@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+u...@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+u...@googlegroups.com. >>> >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> >> >> -- >> Kornelis Sietsma korny at my surname dot com http://korny.info >> .fnord { display: none !important; } >> > -- > You received this message because you are subscribed to the Google > Groups "Clojure" gr
Re: Scheduling state change?
Oups typo in my last reply should be (fn [] ) IPhone quirk, tiny, very tiny keyboard... Luc P. -- 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/d/optout.