clojure.contrib.*

2009-06-19 Thread Justin
Is clojure.contrib.* not included with clojure? I'm reading the book and in chapter two "re-split" doesnt work for me. I may have missed some instructions- was I supposed to install something else? --~--~-~--~~~---~--~~ You received this message because you are

Re: The API docs are gone!

2009-06-27 Thread Justin
This if off-topic but I'm wondering- is there any reason (doc ...) returns a URL instead of documentation for special forms? On Jun 27, 12:29 am, ataggart wrote: > On Jun 26, 9:12 pm, Four of Seventeen wrote: > > > Not that it really matters why it is/was down. The API docs going down > > for

OSCON 2009

2009-07-11 Thread Justin
Is anyone going to OSCON in San Jose in a few weeks? I see this session: http://en.oreilly.com/oscon2009/public/schedule/detail/7917 Anything else clojure-related happening? -justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to

Re: performance question

2008-12-14 Thread Justin Henzie
Nice code chouser, always nice to see a succinct functional example. On Dec 13, 10:15 am, Chouser wrote: > On Sat, Dec 13, 2008 at 10:41 AM, Dmitri wrote: > > > I wrote a simple word counter described herehttp://ptrace.fefe.de/wp/ > > it reads stdin and counts the occurrences of words, however

IntelliJ Plugin

2008-12-26 Thread Justin Johnson
8.0.1 and thought it might be helpful if I document what I did on the wiki. I also have a small suggestion that the build.xml file use environment variables instead of hard coded paths to java.home and idea.home. Thanks, Justin --~--~-~--~~~---~--~~ You received

Re: IntelliJ Plugin

2008-12-29 Thread Justin Johnson
On Sat, Dec 27, 2008 at 8:55 AM, Peter Wolf wrote: > Hi Justin, > This is the right place. Thanks for trying the plugin. > > It would absolutely be helpful to document use of the plugin. However, I > am sure you can tell that it is nowhere near ready. > Yes, I noticed there

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Justin Johnson
in\clojure\completions-clojure.xml.txt E539: Illegal character : complete+=kC:\Program\ Files\Vim\vimfiles\ftplugin\clojure\completions-clojure.zip.txt Do you have any idea what the problem is? Thanks, Justin On Thu, Jan 1, 2009 at 10:23 AM, Meikel Brandmeyer wrote: > Dear vimming Clojurians, >

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Justin Johnson
s . ".txt\""), '\n') if completions != [] call vimclojure#AddPathToOption('k' . completions[0], 'complete') endif endfunction On Fri, Jan 2, 2009 at 10:58 AM, Meikel Brandmeyer wrote: > Hi Justin, > > Am 02.01.2009 um 17:00 schrieb Justin

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Justin Johnson
It looks like my change below just got rid of the errors. However the completion functionality is not working. :( On Fri, Jan 2, 2009 at 1:13 PM, Justin Johnson wrote: > I got it working by adding double quotes around the path, as can be seen in > the "let" line of th

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Justin Johnson
ong, or is it just not working on Windows. Justin On Fri, Jan 2, 2009 at 1:22 PM, Justin Johnson wrote: > It looks like my change below just got rid of the errors. However the > completion functionality is not working. :( > > > On Fri, Jan 2, 2009 at 1:13 PM, Justin Johnson >

Re: Release of VimClojure 1.3.0

2009-01-02 Thread Justin Johnson
rward slashes that would fix it, though I don't know vimscript. :-( On Fri, Jan 2, 2009 at 2:33 PM, Meikel Brandmeyer wrote: > Hi, > > Am 02.01.2009 um 21:06 schrieb Justin Johnson: > > I reinstalled Vim to C:\Vim and reinstalled VimClojure as well. This >> time I don&#

.newInstance error

2009-01-05 Thread Justin Johnson
Will someone please explain to me why this isn't working? Is there something special about newInstance that I'm missing? user=> (. org.tmatesoft.svn.core.wc.SVNClientManager newInstance) # user=> (.newInstance org.tmatesoft.svn.core.wc.SVNClientManager) java.lang.InstantiationException: org.tma

Re: .newInstance error

2009-01-05 Thread Justin Johnson
Ah, static methods... Clearly I haven't spent enough time in the Java world. user=> (org.tmatesoft.svn.core.wc.SVNClientManager/newInstance) # On Mon, Jan 5, 2009 at 8:41 AM, Justin Johnson wrote: > Will someone please explain to me why this isn't working? Is there > some

Collecting items in an interface method call

2009-01-06 Thread Justin Johnson
, but I'm not sure how to do so without having handleDirEntry append them to a list. Is there a more appropriate way to handle this in Clojure? Thanks, Justin (import '(org.tmatesoft.svn.core SVNException ISVNDirEntryHandler)) (import '(org.tmatesoft.svn.core.internal.wc SV

Re: Clojure blog post about laziness

2009-01-10 Thread Justin Henzie
>From my limited understanding it seems that a lazy data structure must at some point reify and therefore be cached, to my mind, the alternative is better describes as a stream or generator. That is not to say that said stream is not the source of the reification but that it might be better to k

Trying to define next-agent function

2009-01-14 Thread Justin Johnson
this time. I'm new to Clojure and am pretty sure there is an elegant way to do what I want, but my little OO head is spinning. Any help you can provide is appreciated. Thanks, Justin => (def counter (ref 0)) #'user/counter => (defn next-counter [] (dosync (alter counter inc))) #&#x

Re: Trying to define next-agent function

2009-01-14 Thread Justin Johnson
I found my problem. I wasn't calling agents. I was doing this. => (defn next-agent [] (nth agents (next-counter))) and should have been doing this. => (defn next-agent [] (nth (agents) (next-counter))) Still, I would like feedback. Is there a cleaner way to do this? Thanks. Jus

Expanding args in (fn [& args]...) to actual args, not ArraySeq

2009-01-14 Thread Justin Johnson
1) (nth args 2))) arg1 arg2 arg3) Thanks, Justin --~--~-~--~~~---~--~~ 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 To unsubscribe from this group,

Re: Expanding args in (fn [& args]...) to actual args, not ArraySeq

2009-01-14 Thread Justin Johnson
Ah, that's right! Thank you. I'm having a hard time thinking functionally. On Wed, Jan 14, 2009 at 12:31 PM, Stuart Halloway wrote: > > Hi Justin, > > Use apply: > > (send-off (next-agent) (fn [v & args] (apply somefn args)) arg1 arg2 > arg3) > > Chee

Only 9 agent "send-off"s complete?

2009-01-14 Thread Justin Johnson
; args] (apply up args)) (str-join "/" [dst-dir p]) IMMEDIATES) (send-off a (fn [_ & args] (apply up args)) (str-join "/" [dst-dir p "branches" "BRANCHNAME"]) INFINITY))) Thanks, Justin --~--~-~--~~---

Re: Only 9 agent "send-off"s complete?

2009-01-15 Thread Justin Johnson
project is the task), with the call to (apply await agents), and ending with (shutdown-agents). Thanks for your response. Justin On Wed, Jan 14, 2009 at 5:47 PM, Timothy Pratley wrote: > > Your omission of (apply await agents) is allowing the program to > terminate before all your creat

Re: contains

2009-01-23 Thread Justin Johnson
On Fri, Jan 23, 2009 at 2:32 PM, Mark Volkmann wrote: > > This must be something I learned months ago and then forgot ... > embarassing! > What's the easiest way to determine if a sequence contains a given value? > I thought there would be something like this: (include? [2 4 7] 4) -> true > That d

Re: Clojure used in Finance?

2009-05-06 Thread Justin Henzie
Interesting question that I have been pondering myself. In the absence of specific evidence to the contrary I think that both languages are worthy of consideration but I think that perhaps the static typing of scala may be more compelling. Just my opinion though. On May 5, 8:11 pm, blais wrote

Re: zip of docs?

2009-07-08 Thread Justin Johnson
It looks like anyone with Organizer rights on Clojure's wikispaces wiki should be able to export an HTML or WikiText backup zip file. Justin On Wed, Jul 8, 2009 at 3:23 PM, Raoul Duke wrote: > > is there an archive of e.g. http://clojure.org/Reference i can > download for o

Re: zip of docs?

2009-07-09 Thread Justin Johnson
No, same thing. If you go to clojure.wikispaces.com it redirects to clojure.org, which is hosted at wikispaces.com. On Wed, Jul 8, 2009 at 5:15 PM, Raoul Duke wrote: > > > It looks like anyone with Organizer rights on Clojure's wikispaces wiki > > should be able to export an HTML or WikiText ba

VimClojureBox

2009-07-14 Thread Justin Johnson
ailgun Server. Does anyone have any thoughts on this? Any suggestions? Thanks, Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googleg

Re: VimClojureBox

2009-07-14 Thread Justin Johnson
vimclojure group defined. I've joined it now and will carry on the conversation there. Thanks. Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

Re: Package manager proposal

2009-08-07 Thread Justin Johnson
> > car: "Clojure Archive" (half-assed pun on Lisp's car, plus you can imagine > the icon!) > +1 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegro

Re: newbie question about ns and :require

2010-01-25 Thread Justin Kramer
You may find this ns cheatsheet helpful: http://gist.github.com/284277 Justin On Jan 24, 10:28 am, Manfred Lotz wrote: > Hi all, > I'm stumbling about the very basics. > > Calling clojure like this: > > rlwrap java > -cp > /home/manfred/clojure/clojure.jar:

Re: ClojureCLR status?

2010-02-27 Thread Justin Bozonier
haha It might be a good idea... I was wondering if it was dead as well. :) On Feb 26, 4:44 am, dmiller wrote: > Two factors: > > (1) I'm working on deftype/protocols/reify and related things.  This > requires some non-trivial re-engineering of the compiler (based on non- > trivial reverse-enginee

Re: Check my idioms?

2010-03-21 Thread Justin Kramer
"\t\n") Justin On Mar 20, 8:22 pm, "Mark J. Reed" wrote: > (I'd say something about my own particular idiom, but that's more of a > Python thing.) > > Anyway, new to Clojure but not to Lisp or Java.  Writing something to > interoperate with some Pe

Re: Splitting a string with the characters between each split?

2010-05-13 Thread Justin Kramer
clojure.contrib.string/partition does exactly what you're looking for. (require 'clojure.contrib.string) (clojure.contrib.string/partition #"\s+" "ab c de") ;; ("ab" " " "c" " " "de") Justin On May 13, 12:24 pm,

Re: swank-clojure and GNU Emacs 23 - package.el install issues

2010-05-17 Thread Justin Kramer
Per Phil Hagelberg's suggestion on IRC, I downloaded and used his package.el, which fixed the issue for me: http://github.com/technomancy/package.el/raw/master/package.el Phil said the bug hasn't been patched upstream. Justin On May 17, 4:18 pm, Terrence Brannon wrote: > Hello

Re: swank-clojure and GNU Emacs 23 - package.el install issues

2010-05-18 Thread Justin Kramer
I should note that I wiped out my elpa dir before using the new package.el. Also, there is this other package.el from Phil's emacs- starter-kit, which may or may not provide different results: http://github.com/technomancy/emacs-starter-kit/raw/master/package.el Justin On May 18, 11:

Re: swank-clojure and GNU Emacs 23 - package.el install issues

2010-05-18 Thread Justin Kramer
Er, to clarify: I believe I wiped out all elpa *packages* before using the new package.el, not the elpa dir itself. Good luck, Justin On May 18, 12:50 pm, Justin Kramer wrote: > I should note that I wiped out my elpa dir before using the new > package.el. Also, there is this other pack

Re: promoting contrib.string to clojure, feedback requested

2010-05-26 Thread Justin Kramer
valent to chomp If clojure.contrib.string/butlast actually mirrored clojure.core/ butlast, it would do the same as chop (c.c.s/butlast requires an extra arg). Justin On May 26, 2:08 pm, Fogus wrote: > > "chomp" has a clear meaning to anyone who's touched Perl/Ruby/shell-

Re: Transient HashMaps with not more than 8 elements?

2010-05-30 Thread Justin Kramer
ce #(assoc %1 %2 %2) {} (range 10)) or (persistent! (reduce #(assoc! %1 %2 %2) (transient {}) (range 10))) Reduce is handy for repeatedly assoc'ing into a hash-map. Justin -- You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: Graph API

2013-06-18 Thread Justin Kramer
As Rob mentioned, I won't be doing further development Loom anytime in the near future. However, if critical mass forms around a fork or alterate project, I'd be happy to add a prominent link in the readme. Justin On Tuesday, June 18, 2013 3:10:23 AM UTC-4, Stephen Kockentiedt wro

Re: (newbie) replace certain values of a map based on a predicate

2013-07-05 Thread Justin Kramer
(result-set-read-column [date] (cl/to-local-date-time date))) Note that result-set-read-column's signature has changed in master; you'll need to update it to [date _ _] in the next release. Justin On Friday, July 5, 2013 4:59:54 PM UTC-4, Colin Yates wrote: > > Hi all, > &g

[ANN] Formative 0.7.2 - now with ClojureScript support

2013-07-26 Thread Justin Kramer
iggieback for making ClojureScript support feasible! Justin P.S., Verily, a sister library which Formative uses for validation, now supports ClojureScript too: https://github.com/jkk/verily -- -- You received this message because you are subscribed to the Google Groups "Clojure" grou

Re: "Clojure in the Large" style JDBC library

2013-09-06 Thread Justin Kramer
clojure.java.jdbc is transitioning to an API that uses explicit passing of db context - see e.g. the db-find-connection and query functions. The functions that look for a dynamically-scoped db are deprecated - e.g., find-connection, with-query-results. Justin On Friday, September 6, 2013 8:20

Rationale behind the naming and semantics for agents.

2015-02-03 Thread Justin Smith
I've used agents, and am familiar with the "reactive agent" concept as presented on the page http://clojure.org/agents I just now decided to look into the background of this distinction (as opposed to the combined state+behavior version of agents that one sees elsewhere) and am stumped. When I

Re: Rationale behind the naming and semantics for agents.

2015-02-03 Thread Justin Smith
In fact agents in Scala were the only version I found that were like Clojure in design. Beyond the fact that they exist in Scala, and the design goal was to replicate Clojure's agents, I didn't find that especially informative. On Tuesday, February 3, 2015 at 6:59:09 PM UTC-8, Leonardo Borges

Re: Rationale behind the naming and semantics for agents.

2015-02-04 Thread Justin Smith
eself embodied in the agent's responsibility for its > own synchronization. > > Of course, as agents were part of the initial Clojure release, only Rich > Hickey can give a definitive answer. > > On Wednesday, 4 February 2015, Justin Smith > wrote: > >> In fact agent

Re: Let bindings and immutability

2015-02-11 Thread Justin Smith
(let [x 0 f #(println x) x 1 g #(println x) x 2] (f) (g) x) there is no mutation of x, only scope shadowing hiding the other binding. Most functional languages (all that I know) allow shadowing. -- You received this message because you are subscribed to the Goo

Re: [newbie] strange behaviour in self-referential primes lazy-seq attempt

2015-02-12 Thread Justin Smith
This is excellent, I was just working out something similar myself. The version using an atom is not idiomatic Clojure, and isn't a translation of the Haskell version either. On Thursday, February 12, 2015 at 4:30:02 PM UTC-8, Armando Blancas wrote: > > Jorge, I tried this on 1.6 and seemed to w

Re: [newbie] strange behaviour in self-referential primes lazy-seq attempt

2015-02-12 Thread Justin Smith
Considering for the sake of argument the possibility that it is a legitimate bug, and not a result of misusing the language features, it is a family of bug that will be more common than most, because it reflects a style of programming that is rare in real Clojure code. But it isn't a bug. Lazy

Re: [newbie] strange behaviour in self-referential primes lazy-seq attempt

2015-02-12 Thread Justin Smith
t; > So why isn't 4 and any even numbers in the result list? Empty primes' > allows everything to pass. We are already beyond this. I've already posted > that even this does not work: > > (def primes (cons 2 (lazy-seq (filter #(prime? primes %) (drop 3 > (range))

Re: [newbie] strange behaviour in self-referential primes lazy-seq attempt

2015-02-12 Thread Justin Smith
ef primes (cons 2 (for [n (drop 3 (range)) :when (prime? primes n)] n))) > > I really hope the actual developers of the language feel differently. At > least there's evidence to support that. > > Cheers, > > Jorge. > > Em sexta-feira, 13 de fevereiro de 2

Re: [newbie] strange behaviour in self-referential primes lazy-seq attempt

2015-02-12 Thread Justin Smith
Not unbound primes, primes as (cons 2 ...). If you look at my post above where I added a print statement to prime? the first 32 inputs see (2) as the value of primes. 32 is the chunking size of the range function. -- You received this message because you are subscribed to the Google Groups "Clo

Re: [newbie] strange behaviour in self-referential primes lazy-seq attempt

2015-02-12 Thread Justin Smith
it's an infinite lazy sequence with itself as a dependency. The first n elements see a value of the initial non-lazy prefix. The alternative would be a compilation error. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send em

Re: [newbie] strange behaviour in self-referential primes lazy-seq attempt

2015-02-12 Thread Justin Smith
it's an infinite lazy sequence with itself as a dependency. The first n elements see a value of the initial non-lazy prefix. The alternative would be a compilation error. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send em

Re: [newbie] strange behaviour in self-referential primes lazy-seq attempt

2015-02-12 Thread Justin Smith
urse not something you can simply figure out from first principles, it takes a bit of exploration and a few mistakes along the way). On Thursday, February 12, 2015 at 9:05:24 PM UTC-8, Justin Smith wrote: > > it's an infinite lazy sequence with itself as a dependency. The first n &g

Re: Generalisation of pre-conditions

2015-02-19 Thread Justin Smith
People complain about stack traces, but precisely the point of having stack traces is that if a pre-condition fails, you don't look at the function with the pre-condition, you look at the function that was calling it. Duplicating pre-conditions to callers, as a general pattern, would scale very

Re: Using type to change the behaviour of a function

2015-02-19 Thread Justin Smith
one approach would be a multi-method for the condition check that doesn't enforce the limit on BigInt user=> (defmulti lucky-numbers-limit type) #'user/lucky-numbers-limit user=> (defmethod lucky-numbers-limit :default [n] (< 0 n 1001)) # user=> (defmethod lucky-numbers-limit clojure.lang.Big

Re: javac-options are ignored

2015-02-20 Thread Justin Smith
This would make sense because javac isn't used to generate those classes. On Thursday, February 19, 2015 at 5:08:33 PM UTC-8, Jeremy Heiler wrote: > > On February 19, 2015 at 4:40:16 PM, Felipe Gerard (fge...@interware.com.mx > ) wrote: > > When you set: > > > > :javac-options ["-target" "1.

Re: Is Caribou Dormant ?

2015-02-28 Thread Justin Smith
I'm one of the core devs of the Caribou project. Caribou has been less actively developed, but I still use it frequently. We previously were funded to work on Caribou, but the company funding us decided to discontinue using Clojure (except for supporting some clients where Clojure code was depl

Re: How to persist a value while doing do-seq

2015-03-04 Thread Justin Smith
Consider using for, and returning the new set of values (for [[a b] (partition 2 1 coll)] (if (= (:foo a) (:foo b)) (dissoc a :foo) a)) Here I use partition so that each item can be compared to the one that follows it. You would likely want a final step that tacks on the last it

Re: Incanter rendering a blank window

2015-03-28 Thread Justin Smith
I've had issues with JVM GUIs and tiling window managers, sometimes floating and then tiling the window (or even hiding/ showing the window, or resizing) will make the contents show up. I don't know if there is an application level fix for this, and I'm not sure whether it should be considered

Re: How do I upgrade nREPL?

2015-03-29 Thread Justin Smith
You can use a newer version by putting your nrepl dep under the :dev profile, which will override the version that leiningen wants. On Sunday, March 29, 2015 at 11:46:55 PM UTC-7, Tassilo Horn wrote: > > Shannon Severance > writes: > > > I would like to upgrade nREPL, but it appears I am still u

Re: clojure, not the go to for data science

2015-04-02 Thread Justin Smith
Emacs can use the native windowing system on every major platform. It still *looks* like a terminal app, but doesn't have to be one. Pretty much everything you are saying here doesn't apply to Emacs at all, and you would know it's all false if you knew anything about Emacs. On Wednesday, April

Re: Clojure needs a web framework with more momentum

2015-05-05 Thread Justin Smith
Wow, what a thread! As one of the authors and designers of Caribou, I have a couple of clarifications to offer. When the initial post compared contributors and commits, it picked our "caribou" repo, which, while extensive, holds no code, only our docs. The actual code is in caribou-core (persi

Re: One more argument for cyclic dependencies

2015-05-20 Thread Justin Smith
I'll second the recommendation to use protocols or interfaces to solve this. Clojure is fairly opinionated in that the tools available should push you toward developing against interfaces or protocols rather than concrete implementations. Things become much simpler when you accept this. You can

Re: [ANN] Clojure 1.8.0-alpha2

2015-07-28 Thread Justin Smith
I use agents instead of atoms when the function altering the value has side effects, or is especially expensive (and thus should not retry). I haven't had to use refs yet, but my use case would be if the mutable data has enough parallel modification that splitting one atomic map into separate r

Re: [ANN] Pink 0.2.0, Score 0.3.0

2015-07-28 Thread Justin Smith
Overtone has its own composition logic, but for synthesis it is a client for the open source Supercollider audio synthesis server (which is a cross platform C++ program that can be controlled via the network). Pink and Score are built in Clojure and Java without using an external server. On Tue

Re: multimethod, record, type, and protocol pitfalls?

2014-11-11 Thread Justin Smith
Helping newcomers to the language on #clojure, I often find the need to use a protocol in reference to it's namespace rather than the namespace of the datatype extending it is a counter-intuitive one for people learning the language. Similar with dispatch methods. Speculatively, I think it has

Re: first time without state - and I'm lost

2020-06-15 Thread Justin Smith
The usage of delay here is clever. I suggest as an addition, using `force` instead of `deref` to disambiguate delay vs. atom (of course if you take a few moments to think about it, swap! shouldn't return an atom etc., but I think it becomes clearer with force). On Mon, Jun 15, 2020 at 10:34 AM Ern

Re: Accessing Record fields with keywords in ClojureScript not working as in Clojure

2020-08-04 Thread Justin Smith
I don't think this is true, or if true is incidental to the real problem % cljs ClojureScript 1.10.758 cljs.user=> (defrecord Attr [has-default default]) cljs.user/Attr cljs.user=> (get (->Attr true 1) :default) 1 cljs.user=> (:default (->Attr true 1)) nil cljs.user=> On Tue, Aug 4, 2020 at 11:53

Re: clojure.edn/read isn't spec compliant

2020-10-17 Thread Justin Smith
not only does clojure.edn accept invalid input, but the clojure reader also accepts invalid input for the same reason (prioritizing speed of implementation over validation) user=> (name 'a/b/c) "b/c" On Sat, Oct 17, 2020 at 5:14 PM William la Forge wrote: > > My understanding is that run-time va

Re: How to safely print structures that may contain infinite lazy seqs?

2020-11-02 Thread Justin Smith
> The next step might be to investigate why infinite lazy seqs don't print as > clojure.lang.LazySeq, like the finite ones. that printing of "clojure.lang.LazySeq@c5d38b66" relies on completely realizing the input, as it relies on the hash, which relies on the fully realized value On Mon, Nov 2

Re: How to safely print structures that may contain infinite lazy seqs?

2020-11-02 Thread Justin Smith
ang.IHashEq java.util.Collection clojure.lang.IObj clojure.lang.Sequential clojure.lang.Seqable clojure.lang.IPersistentCollection clojure.lang.ASeq clojure.lang.IReduce java.lang.Object clojure.lang.ISeq clojure.lang.IMeta clojure.lang.IReduceInit} On Mon, Nov 2, 2020 at 12:36 PM Justin Smith wrote: > > >

Re: Idiomatic program for someone new to Clojure

2020-12-14 Thread Justin Smith
a small suggestion: you don't need to nest let inside let, a clause can use previous clauses: (defn get-latest-build [pipeline] (let [response (fetch-pipeline pipeline) json (parse-string (:body response) true) [pipeline] (:pipelines json)] (:counter pipeline also conside

Re: Socket servers, threads, and redirecting error output.

2021-01-02 Thread Justin Smith
By the time the exception is caught, you are already outside the context of the Thread which the repl client is interacting with. The default exception handler has no information tying the executing thread to the repl process (not to mention the dynamic variables clojure is using to associate outpu

Re: Socket servers, threads, and redirecting error output.

2021-01-02 Thread Justin Smith
to be clear, in my second example you see the error from the future without using deref good luck finding your solution On Sat, Jan 2, 2021 at 12:50 PM Austin Haas wrote: > Thank you very much for the explanation, Justin. > > I don't see how I can use futures, though, without b

[Remote Job Opportunity] Senior Software Engineer for Health Tech Company

2021-01-05 Thread Justin L
Hi all, I am working with a client to hire Senior Software Engineers with experience using Clojure or another functional programming language. If you are interested please let me know and I can set up a time to connect directly. Please see some details: *What You'll Be Doing:* - Deliver

Re: How get function name in body?

2021-05-03 Thread Justin Smith
there's a handy trick for pulling in the standard repl aliases / refers: (cmd)user=> clojure.main/repl-requires [[clojure.repl :refer (source apropos dir pst doc find-doc)] [clojure.java.javadoc :refer (javadoc)] [clojure.pprint :refer (pp pprint)]] (ins)user=> (ns foo.bar) nil (ins)foo.bar=> (doc

Re: Library like "infix"...

2021-05-17 Thread Justin Smith
unless this is an exercise in learning clojure, why not use an existing calculator parser? eg. https://inst.eecs.berkeley.edu/~cs164/sp05/ta/calculator/Parser.java for a random example found with a quick google On Sat, May 15, 2021 at 3:23 PM Blake Watson wrote: > Hello, > > I've got a situation

Re: How to get a value of a var in Java

2021-06-24 Thread Justin Smith
> Clojure vars under the IFn interface. In other words, you can only import Clojure functions, not Clojure values, through that API. On Fri, Jun 18, 2021 at 12:29 PM ru wrote: > Thank you, Gary, for the comprehensive answer. I have a control over > Clojure side, so I decide to add special funct

Re: How to get a value of a var in Java

2021-06-24 Thread Justin Smith
(sorry, hit reply too soon) On Thu, Jun 24, 2021 at 9:42 AM Justin Smith wrote: > > Clojure vars under the IFn interface. In other words, you can only > import Clojure functions, not Clojure values, through that API. > > On Fri, Jun 18, 2021 at 12:29 PM ru wrote: > >>

Re: How to get a value of a var in Java

2021-06-24 Thread Justin Smith
here) On Thu, Jun 24, 2021 at 9:43 AM Justin Smith wrote: > (sorry, hit reply too soon) > > On Thu, Jun 24, 2021 at 9:42 AM Justin Smith wrote: > >> > Clojure vars under the IFn interface. In other words, you can only >> import Clojure functions, not Clojure values

Re: potential bug with pr-str+print

2017-05-02 Thread Justin Smith
there's something going on with dynamic bindings here peregrine.circle=> (let [xs (map #(pr-str %) ["a" "b"])] (println xs)) (a b) nil peregrine.circle=> (let [xs (doall (map #(pr-str %) ["a" "b"]))] (println xs)) ("a" "b") nil On Tue, May 2, 2017 at 1:55 AM Paulus Esterhazy wrote: > Looks lik

Re: feedback on file parsing with Clojure

2017-06-16 Thread Justin Smith
The primary suggestion I'd make here is to replace the doseq/reset! construction in your main loop with reduce using a hash-map accumulator representing each value you are updating with a separate key. This isn't just more idiomatic, it also performs better. Instead of: (let [hexagrams (atom (sor

Re: Seeking a function to partially parallelize collection processing

2017-06-16 Thread Justin Smith
pmap is rarely actually useful, but point 1 is false, pmap doesn't require that it's input or output fit in memory On Fri, Jun 16, 2017 at 12:52 PM Tom Connors wrote: > Hello Jose, > Thank you for the response, but pmap does not address my use case. It's > insufficient for two reasons: 1) the en

Re: Seeking a function to partially parallelize collection processing

2017-06-20 Thread Justin Smith
Aside from style issues of mixing channel input/output with program logic, and hiding the useful return value of go-loop, the real problem here is doing your work inside a go block. Go blocks are not meant for blocking tasks, whether CPU or IO bound; doing real work inside go blocks risks starving

Re: Seeking a function to partially parallelize collection processing

2017-06-20 Thread Justin Smith
https://www.youtube.com/watch?v=096pIlA3GDo On Tue, Jun 20, 2017 at 11:44 AM Tom Connors wrote: > Thanks, Justin. Regarding the mixing of program logic with channel io, I'm > don't understand why that's a problem in this case or how it could be > improved. Do you mi

Re: Why does gen-class executes with *ns* bound to clojure.core?

2017-06-20 Thread Justin Smith
*ns* is a dynamic var, so it points to the current namespace when your function is running. Most code doesn't switch into a target ns in order to execute functions from it. On Tue, Jun 20, 2017 at 4:51 PM Didier wrote: > Especially given this: > > (ns dda.main > (:gen-class)) > > (def should-e

Re: def partially done when used in if

2017-06-29 Thread Justin Smith
Clojure's compiler (there's no interpreter) creates vars for every def inside a form it compiles. Before the def actually runs it's unbound (as if you had used declare). Generally def and defn that are not top level forms are signs of a bad design. If you need runtime rebinding use a proper mutabl

Re: def partially done when used in if

2017-06-29 Thread Justin Smith
are "generally" a sign of bad design. There are of course special cases where they might be the least bad option. On Thu, Jun 29, 2017 at 3:15 PM Kaiming Yang wrote: > Thanks Justin, > > Sadly in my case those mutable container will not work because I was > making a

Re: I can only get the first item of a lazyseq via a Manifold stream, and I can't get/find an Exception

2017-07-11 Thread Justin Smith
My first suspicion would be that by the time you access the second element, you have exited the context of your database transaction, so there's no data stream available to get it from. Lazyness doesn't tend to mix well with stateful resources and contexts. On Mon, Jul 10, 2017 at 9:45 PM wrote:

Re: I can only get the first item of a lazyseq via a Manifold stream, and I can't get/find an Exception

2017-07-11 Thread Justin Smith
Oh - this appears to be a separate issue that isn't just about leaving the context of the db transaction, I don't know enough about those parts of manifold to address the issue, sorry. On Tue, Jul 11, 2017 at 1:18 PM wrote: > Justin, thanks. I'd like to ask a follow up questio

Re: What is juxt really doing?

2017-07-15 Thread Justin Smith
juxt uses each of the functions supplied on all of your arguments. The hash-map for :what is because (:what {} :default) returns :default - it's invoking get, which takes an optional "not found" argument. On Sat, Jul 15, 2017 at 8:52 PM wrote: > If I do this: > > ((juxt :who :what :when) {:who 1

Re: [ANN] clojure.java.jdbc 0.7.0 Beta 2

2017-07-22 Thread Justin Smith
refer-clojure doesn't ever remove mappings, it only adds them The reason a refer-clojure clause in your ns form can prevent bindings is because your refer-clojure clause (which is likely more qualified than the default) overrides the args that ns would otherwise provide to refer-clojure. On Sat

Re: printing self referential data?

2017-07-23 Thread Justin Smith
You can prevent the need for mutable nodes by using an adjacency list to represent a graph structure. In clojure this works nicely as a hash-map from a node id to a set of connected node ids (eg for your case, a set of parent nodes and a set of child nodes), and traversal becomes a series of lookup

Re: printing self referential data?

2017-07-24 Thread Justin Smith
One important thing to be aware of that I should have mentioned when suggesting the adjacency list solution is the rationale for using that representation. When you put atoms in the nodes of your data structure, it's no longer an immutable data structure and you lose the usage patterns that clojure

Re: how to be notified when a Future is realized?

2017-08-02 Thread Justin Smith
for this sort of logic, I use core.async go blocks containing a call to core.async/thread, doing some other operation asynchronously with the value in the channel it returns (go (let [result (https://gist.github.com/noisesmith/02ee2ee5dcb8c0290bd8004c4c4d36aa On Wed, Aug 2, 2017 at 2:09 PM wro

Re: SRSLY? (= (true? identity) (false? identity)) => true

2017-09-01 Thread Justin Smith
This is what I would expect - the identity function is neither the value true, or the value false On Fri, Sep 1, 2017 at 8:44 PM Rostislav Svoboda < rostislav.svob...@gmail.com> wrote: > Hi, can anybody explain it please? > > $ java -cp clojure-1.8.0.jar clojure.main > Clojure 1.8.0 > user=> (= (

Re: SRSLY? (= (true? identity) (false? identity)) => true

2017-09-01 Thread Justin Smith
You seem to be confused about what true? and false? are intended to do. +user=> (doc true?) - clojure.core/true? ([x]) Returns true if x is the value true, false otherwise. nil +user=> (doc false?) - clojure.core/false? ([x]) Returns true if x is

Re: SRSLY? (= (true? identity) (false? identity)) => true

2017-09-01 Thread Justin Smith
identity isn't a boolean, so neither true? nor false? should return true for it On Fri, Sep 1, 2017 at 9:01 PM Rostislav Svoboda < rostislav.svob...@gmail.com> wrote: > > (true? identity) -> false > > (false? identity) -> false > > (= false false) -> true > > Well: > (= identity identity) -> tru

Re: Why is the start function called -main

2017-09-06 Thread Justin Smith
To define a method in gen-class you need to use a prefix on the function name, "-" is the default prefix On Wed, Sep 6, 2017, 14:41 Cecil Westerhof wrote: > 2017-09-06 23:27 GMT+02:00 Matching Socks : > >> There is a hint, as to this, in the API doc of gen-class: >> >> >> https://clojure.github.

Re: varying realization of a lazy-seq of strings?

2017-09-17 Thread Justin Smith
my simplified reproduction of the issue: +user=> (let [mk-str (fn [] (lazy-seq [(str ["ZiZi"])])) a (mk-str) b (mk-str)] (print-str a) (pr-str b) [a b]) [("[ZiZi]") ("[\"ZiZi\"]")] isn't *print-readably* the difference between pr-str and p

  1   2   3   >