Re: Using xlisp assoc-lists in clojure

2013-11-21 Thread Justin Smith
The issue, as far as I am concerned, is not that clojure cannot do alists as any traditional lisp would (it can, quite easily, as has already been shown). The real question is why you would use a linked list for associative data, when you have an associative type with better lookup time and a

Re: preferred way to dereference a ref: outside or inside dosync?

2013-11-23 Thread Justin Smith
you may want to make that (defonce generate-keys (get-key-generator)) and even better, add a start argument to get-key-generator so you can persist across restarts of the vm. Of course in a real app the key should be serialized to a persistent, consistent, and shared data store. On Friday,

Re: Releasing Caribou today: Open Source Clojure Web Ecosystem

2013-11-23 Thread Justin Smith
I have successfully run a fresh caribou site on Windows 8, with the latest default 64 bit jdk from sun. You may need to explicitly supply a -Xmx argument to your jvm (I don't know how predictable the default maximums are). You are welcome to post issues on our github pages. If we made a forum

Re: .cljrc

2013-11-28 Thread Justin Smith
the leinengen project has an example project.clj https://github.com/technomancy/leiningen/blob/master/sample.project.clj On Wednesday, November 27, 2013 4:53:02 PM UTC-8, Dave Tenny wrote: Thanks, I seem to have accomplished what I need for now. It was a bit frustrating to figure out exactly

Re: Am I missing something?

2013-12-05 Thread Justin Smith
I happen to be working on the prototype for the caribou plugin layer right now (which may or may not be related to what you mean by pluggable). The default caribou template combines a number of libs that can in many cases be used independently of one another. We use ring and clojure.java.jdbc

Re: java.jdbc not working with my jdbc driver

2013-12-06 Thread Justin Smith
Parenthesis call the thing they wrap as a function. You have getConnection wrapped in a redundant set of parenthesis, so the return value of getConnection is being called. It is not a function, but it is a ConnectionCustom, so you get your error. Some hints to make clojure code more readable:

Re: java.jdbc not working with my jdbc driver

2013-12-06 Thread Justin Smith
to slow down and consciously read it as lisp, rather than automatically knowing which I am seeing based on the paren placement. On Friday, December 6, 2013 5:30:57 AM UTC-8, Justin Smith wrote: Parenthesis call the thing they wrap as a function. You have getConnection wrapped in a redundant

Re: Caribou admin page: No template by the name login.html

2013-12-14 Thread Justin Smith
This is a known issue https://github.com/caribou/caribou-frontend/issues/3with caribou under Windows, with a potential fix upcominghttps://github.com/caribou/caribou-core/pull/20 . On Saturday, December 14, 2013 8:45:01 AM UTC-8, Niels van Klaveren wrote: Could it have something to do with

Re: How do I serve clojure pages with nginx

2013-12-26 Thread Justin Smith
java -jar is fine in production. Jetty, Tomcat, or Immutant will offer some conveniences but are not necessary. What is needed (for security reasons) is an nginx proxy. On Wednesday, December 25, 2013 3:42:00 AM UTC-8, Zeynel wrote: Ok, I worked through the tutorial referenced

Re: Require namespace

2014-01-05 Thread Justin Smith
Agreed, sticking with require scales better than load-file, and require is actually the right way to use functionality in another ns. load-file is a clumsy tool and you will hit its limits quickly. On Sunday, January 5, 2014 8:54:18 AM UTC-8, Tim Visher wrote: Hi juanghui, If you're

Re: order of returned values from keys and vals

2014-02-01 Thread Justin Smith
Realistically, how many situations are there where running keys and vals independently is preferable to running seq once and using the two element vectors that returns? Usually this way one can avoid walking the whole thing twice. (into {} (map (fn [[k v]] [k (inc v)]) {:a 0 :b 1})) is

Re: order of returned values from keys and vals

2014-02-01 Thread Justin Smith
addition). keys/vals are also lazy, so I would be surprised if there was any performance difference with walking the seq twice. Thanks, Ambrose On Sun, Feb 2, 2014 at 11:35 AM, Justin Smith noise...@gmail.comjavascript: wrote: Realistically, how many situations are there where running keys

Re: order of returned values from keys and vals

2014-02-01 Thread Justin Smith
of the KeySeq. Thanks, Ambrose On Sun, Feb 2, 2014 at 12:18 PM, Michał Marczyk michal@gmail.comjavascript: wrote: On 2 February 2014 05:14, Justin Smith noise...@gmail.com javascript:wrote: Pardon my ignorance but if this is producing a lazy result, how is it doing so? https://github.com

Re: order of returned values from keys and vals

2014-02-01 Thread Justin Smith
@gmail.comjavascript: wrote: I'd expect (persistent! (reduce-kv (fn [acc k v] (assoc! acc k (inc v))) (transient {}) input-map)) to be the fastest solution. Cheers, Michał On 2 February 2014 05:30, Justin Smith noise...@gmail.com javascript:wrote: Excellent, thanks

Re: Programming clojure second Edition

2014-02-03 Thread Justin Smith
if pred is false or nil (the two cases when would rule out), it would be an error to apply it to an argument #{\a \b} is a literal set syntax, containing keys \a and \b. {\a \b} is a literal hash-map syntax, with one key \a mapped to the value \b. As far as index-filter is concerned, it only

Re: STM and persistent data structures performance on mutli-core archs

2014-04-10 Thread Justin Smith
One could quantify this with Category Theory. In order to map from one domain to another reversibly, the target domain must have at least as many elements as the source domain, if not more. An abstraction which simplifies by reducing the number of elements in play is guaranteed to be leaky. Of

Re: Idiomatic Clojure for iterating all items of a map

2014-04-21 Thread Justin Smith
That doseq is a no-op, because str has no side effects and doseq always returns nil. Also there is no need to nest doseq calls. for is much like doseq except it actually returns the result. user (for [lang (:langs langs) k (keys lang)] (str k(k lang))) (:lang

Re: Idiomatic Clojure for iterating all items of a map

2014-04-21 Thread Justin Smith
small correction: sometimes one does need to nest a for or doseq call, but not for the usual nested iteration case On Monday, April 21, 2014 8:57:49 AM UTC-7, Justin Smith wrote: That doseq is a no-op, because str has no side effects and doseq always returns nil. Also there is no need

Re: How to interrupt execution and open a debugger/REPL?

2013-11-12 Thread Justin Smith
On Tuesday, November 12, 2013 4:21:26 AM UTC-8, Lee wrote: On Nov 12, 2013, at 1:58 AM, juan.facorro wrote: Hi Alexandru, As Andy pointed out there's the emacs+Ritz option which has quite a few features, but if the main thing you want to do is inspect the locals and the current

Re: Releasing Caribou today: Open Source Clojure Web Ecosystem

2013-11-12 Thread Justin Smith
Typically my first step making a caribou app is to remove the immutant dependency. It's pretty straightforward to take it out. On Tuesday, November 12, 2013 9:19:27 PM UTC-8, Prasanna Gautam wrote: This is really cool. Very easy to get up and running for first try. I have a few questions on

Re: Do web apps need Clojure?

2013-11-13 Thread Justin Smith
Hi. I'm part of the Caribou team, which started as an in-house tool (and continues to serve that purpose). A few advantages of clojure in the webapp space, off the top of my head: Clojure provides execution efficiency that Ruby or Python cannot match. This translates to lowered hosting costs.

Re: Do web apps need Clojure?

2013-11-13 Thread Justin Smith
it is pretty simple. On Wednesday, November 13, 2013 3:49:16 PM UTC-8, Marcus Blankenship wrote: Thanks, Justin. These are great points! I especially like the simplicity of deployment. Do you folks use Heroku, AWS, or some other hosting service? On Nov 13, 2013, at 3:23 PM, Justin Smith noise

Re: Do web apps need Clojure?

2013-11-14 Thread Justin Smith
On Thursday, November 14, 2013 10:23:40 AM UTC-8, Stanislav Sedov wrote: 3) General lack of decent tools. The only jvm debugger, jdb, while nice, does not allow you to attach to an already running process like gdb would. Profiling tools are pretty much GUI only so won't

Re: Caribou: custom templates shadow _admin templates

2013-11-15 Thread Justin Smith
The your own resources subdirectory is merged over the admin one, the structure visible here: caribou admin templateshttps://github.com/caribou/caribou-admin/tree/master/resources/templates And yes, anything which has the same directory structure in your project is merged over the admin

Re: Caribou: custom templates shadow _admin templates

2013-11-15 Thread Justin Smith
Update: I have created a namespaced-templates branch of caribou-admin, and the fix actually looks like it will be a shallow change (if moderately tedious given our lack of relative partial paths in templates which gives me another idea...). On Friday, November 15, 2013 6:36:30 AM UTC-8, Justin

Re: Caribou: custom templates shadow _admin templates

2013-11-15 Thread Justin Smith
branch of the caribou-admin projecthttps://github.com/caribou/caribou-admin/tree/namespaced-templatesif you would like to help and submit a pull request. On Friday, November 15, 2013 10:01:23 AM UTC-8, Tassilo Horn wrote: Justin Smith noise...@gmail.com javascript: writes: Hi Justin

Re: Caribou: custom templates shadow _admin templates

2013-11-15 Thread Justin Smith
And yes, you could still customize by overriding the templates in their new path (which all being under _admin would not reasonably conflict with an app that intends to use the admin). On Friday, November 15, 2013 10:20:25 AM UTC-8, Justin Smith wrote: Yes, I've made significant progress

Re: [ANN] overload-middleware 0.1.1

2013-11-16 Thread Justin Smith
I've use many services within apps that are json or xml results served over HTTP. This is a common way to integrate third party data or functionality into an app (especailly webapps or mobile apps). On Saturday, November 16, 2013 2:49:46 PM UTC-8, Cedric Greevey wrote: On Sat, Nov 16, 2013 at

Re: Releasing Caribou today: Open Source Clojure Web Ecosystem

2013-11-17 Thread Justin Smith
I don't know if this is what Ronen is asking for, but I have had requests that we serve an instance with the admin open somewhere, so people can try out the whole app without installing it and getting it running locally. On Sunday, November 17, 2013 11:49:50 AM UTC-8, Ryan Spangler wrote:

Re: Using xlisp assoc-lists in clojure

2013-11-18 Thread Justin Smith
Typically in clojure we use hash-maps (represented literally as {}) where other lisps would use an alist. Regarding reading assoc list literals, I wouldn't be surprised if someone had written this function already, but I doubt it is in the core language. I also don't think it would be hard to

Re: Releasing Caribou today: Open Source Clojure Web Ecosystem

2013-11-18 Thread Justin Smith
Check out resources/config/*.clj. production.clj includes a postgres config that you can customize (I notice now that we should include an example mysql config in there too actually). Once you have a config set up and pointing to an empty db in the appropriate environment, you can use the lein

Re: Releasing Caribou today: Open Source Clojure Web Ecosystem

2013-11-18 Thread Justin Smith
We only include the h2 db to lower friction for creating a project and trying it out - I have never used h2 in an actual production app. On Monday, November 18, 2013 5:23:16 AM UTC-8, Justin Smith wrote: Check out resources/config/*.clj. production.clj includes a postgres config that you can

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

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
Hickey can give a definitive answer. On Wednesday, 4 February 2015, Justin Smith noise...@gmail.com javascript: wrote: 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

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

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

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

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

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

2015-02-12 Thread Justin Smith
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 elements see a value of the initial non-lazy prefix. The alternative would be a compilation

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.

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

2015-02-12 Thread Justin Smith
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)) Em sexta-feira, 13 de fevereiro de 2015 00:39:03 UTC-2, Justin Smith escreveu

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

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

2015-02-12 Thread Justin Smith
developers of the language feel differently. At least there's evidence to support that. Cheers, Jorge. Em sexta-feira, 13 de fevereiro de 2015 00:39:03 UTC-2, Justin Smith escreveu: Considering for the sake of argument the possibility that it is a legitimate bug, and not a result of misusing

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

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)) #MultiFn clojure.lang.MultiFn@7533f6b5 user= (defmethod

Re: How do I upgrade nREPL?

2015-03-30 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 s...@s53.me javascript: writes: I would like to upgrade nREPL, but 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 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

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

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 javascript:) wrote: When you set: :javac-options [-target

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

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: 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: Interop with strange java type: java.lang.String

2015-08-20 Thread Justin Smith
I suspect this is it. Also, remember that internally a varargs string method will take an Array of String as its last arg. On Thursday, August 20, 2015 at 9:35:19 AM UTC-7, squeegee wrote: On Aug 20, 2015, at 3:32 AM, Andy Dwelly andyd...@gmail.com javascript: wrote: Does anyone know how

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

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

Re: The following behavior of into function is a bug or the intended result?

2015-08-09 Thread Justin Smith
PersistentArrayMap is automatically promoted to PersistentHashMap when it reaches a specific size. This is done for performance reasons. Neither collection is considered ordered, and you should use a different datatype if you want ordered data. On Sunday, August 9, 2015 at 6:31:20 PM UTC-7,

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

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

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: > >

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

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

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

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
n the second row is never > processed. > > So are you suggesting that simply passing "data" from one function to the > next is enough to lose the database context? But only after the first row > has been pulled? > > > > > > > On Tuesday, July 11, 2017 at

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

Re: def partially done when used in if

2017-06-29 Thread Justin Smith
time to make it work > but I would still expect *correct* result. "An undefined behavior" would be > a more suitable. > > > On Thursday, June 29, 2017 at 1:15:23 PM UTC-7, Justin Smith wrote: > >> Clojure's compiler (there's no interpreter) creates vars fo

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 >

Re: Seeking a function to partially parallelize collection processing

2017-06-20 Thread Justin Smith
channel operations are io, and intermixing them with processing leads to code that is difficult to read and debug. core.async has facilities to help you code more declaratively over channels. I think TImothy Baldridge's talk at the last Clojure/West does a great job of presenting the issue

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-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

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

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

Re: functions with metadata, 2 problems: performance hit and equality not preserved.

2017-09-20 Thread Justin Smith
I've had good luck with an approach suggested by Kevin Downey, defining a defrecord that implements IFn so that it works when called and applied, and transparently supporting attached data as if it were a hash-map. It's not too hard to implement if you know the precise arg count you need to

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

Re: hello world question !!!

2017-10-16 Thread Justin Smith
the uberjar option bundles clojure.jar (as well as any other dependencies you specify in your project.clj) into the output jar for you On Mon, Oct 16, 2017 at 6:36 AM Damien Mattei wrote: > following this tutorial : >

Re: hello world question !!!

2017-10-13 Thread Justin Smith
paths have to reflect the package and be relative to the class path, so if "clojure/examples" is on the classpath, and the namespace is clojure.examples.hello, the file needs to be in "clojure/examples/clojure/examples/hello.clj" On Fri, Oct 13, 2017 at 10:13 AM Damien Mattei

Re: hello world question !!!

2017-10-13 Thread Justin Smith
Sorry for the auto correct fail, it compiles all of your code to byte-code On Fri, Oct 13, 2017, 08:29 Justin Smith <noisesm...@gmail.com> wrote: > To pedantically specific, clojure compiles all of your coffee to be code > in memory, but the 'compile' function expects to find a

Re: hello world question !!!

2017-10-13 Thread Justin Smith
To pedantically specific, clojure compiles all of your coffee to be code in memory, but the 'compile' function expects to find a file on disk, and create a class file on disk. Using gen-class in the repl is a no-op. On Fri, Oct 13, 2017, 07:48 James Reeves wrote: > Maybe

Re: form comment and meta data?

2017-10-13 Thread Justin Smith
what happens is that the metadata reader macro is applied before the comment reader macro, so you comment out the name of the def (which also had the metadata attached) user=> '(def #_ ^:private foo 1) (def 1) On Fri, Oct 13, 2017 at 11:48 AM Rob Nikander wrote: > Hi, >

Re: hello world question !!!

2017-10-13 Thread Justin Smith
also you don't need to do any of this for a basic example, you can just type code into the repl and run it, or create a proper project with a dependency manager when you want something more organized On Fri, Oct 13, 2017 at 10:22 AM Justin Smith <noisesm...@gmail.com> wrote: > p

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

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

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) ->

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: possibly a Clojure question or possibly an AWS question: slow writes to durable-queue

2017-10-11 Thread Justin Smith
a small thing here, if memory usage is important you should be building and running an uberjar instead of using lein on the server (this also has other benefits), and if you are doing that your project.clj jvm-opts are not used, you have to configure your java command line in aws instead On Wed,

Re: (resolve (symbol f)) works at the REPL but not in an uberjar

2017-10-12 Thread Justin Smith
you can use (symbol "denormalize.pull-from-mysql" "f") instead On Thu, Oct 12, 2017 at 6:34 PM wrote: > Nevermind. I found that this works, though I think it is ugly and > inelegant: > > resolved-f (resolve (symbol (str "denormalize.pull-from-mysql/" > f)))

Re: difference between first & peek; rest & pop

2017-11-10 Thread Justin Smith
first and rest are defined in terms of position, and work on anything that can be treated as an ordered collection peek and pop work in terms of "natural insertion order" and only work with things that behave like a stack - (so not lazy-seqs, strings, etc.) lists push and pop from the front,

Re: Slow -main function termination by pmap

2017-12-19 Thread Justin Smith
any Clojure program that uses the built in thread pools (future, agent, pmap, core.async, etc.) should call (shutdown-agents) if prompt exit is needed On Tue, Dec 19, 2017 at 12:05 PM Jacek Grzebyta wrote: > Hi, > > I have multi -mains project. Thus the execution looks

Re: An Annotation within an Annotation

2017-11-01 Thread Justin Smith
when you use ^{}, that applies metadata to the next form. In the highlighted code, you are trying to put metadata on the keyword :component - perhaps the ^TestType metadata should go on the hash-map on that line instead of turning the whole hash-map into metadata ? On Wed, Nov 1, 2017 at 7:37 AM

Re: What's up with IMeta?

2017-11-04 Thread Justin Smith
first class values on the jvm are objects On Sat, Nov 4, 2017 at 5:57 PM Didier wrote: > > That said, metadata and its relationship to an object is immutable - an >>> object with different metadata is a different object. One consequence of >>> this is that applying metadata

Re: Terminating 'clj' REPL session

2017-12-09 Thread Justin Smith
I find the fact that "exit" and "quit" work in leiningen repls to be weird - this doesn't follow the otherwise consistent rules of the language. What about an exit function, something like (defn exit ([] (exit 0)) ([n] (System/exit n)) so that it's not an out of band special case input? On

Re: Got NullpointerException when using loop/recur/let together

2017-10-24 Thread Justin Smith
you wrap a call to Thread/sleep in parens, in clojure this means you want to call it, Thread/sleep returns nil and calling nil gives a NullpointerException Parens are not for grouping or sequencing things in clojure, and you don't need them here - fn has an implicit do block already, in other

Re: Plain clojure 1.9 fails with Could not locate ... clojure/spec/alpha.clj on classpath. in Kubuntu 18.04

2018-05-21 Thread Justin Smith
this is a problem with your distribution's config for installing the vm, on debian based systems it can be fixed by forcing reinstall of ca-certs, it does not require an oracle vm On Mon, May 21, 2018 at 10:30 AM Jesús Gómez wrote: > I followed the Getting Started guide and

Re: Plain clojure 1.9 fails with Could not locate ... clojure/spec/alpha.clj on classpath. in Kubuntu 18.04

2018-05-21 Thread Justin Smith
I should have been more specific. Just uninstalling leaves old configs around, and fixing this requires a full purge of the package. these are my steps on a debian system: $ sudo dpkg --purge --force-depends ca-certificates-java $ sudo apt-get install ca-certificates-java sourced from this

Re: doall

2018-05-16 Thread Justin Smith
as an aside, :1 etc. are bad keywords (accepted by some readers and not others, technically not valid according to the docs), and usually the presence of keywords like that indicates over-eager keywordizing of json input, or a misunderstanding of clojure hash-maps On Wed, May 16, 2018 at 12:38 PM

Re: core.async buffered channel behavior

2018-06-27 Thread Justin Smith
I doubt core.async would ever make promises about the behavior of a blocking put that gets forcibly cancelled. It promises that the blocking put doesn't return until the message is consumed, but that's not the same as promising that the message isn't consumed if the blocking put is forcibly

Re: core.async buffered channel behavior

2018-06-27 Thread Justin Smith
I should be more precise there, by "consumed" I meant buffered or consumed. On Wed, Jun 27, 2018 at 10:17 AM Justin Smith wrote: > I doubt core.async would ever make promises about the behavior of a > blocking put that gets forcibly cancelled. It promises that the blocking >

Re: Custom core.async go threadpools? Using go parking for heavy calculation parallelism throughput?

2018-05-01 Thread Justin Smith
Just a couple of small points (and not yet a full answer): > A node can obviously not pmap over all the child nodes (would spawn exponential amount of threads) pmap is not that naive, it uses a pool sized with the assumption that its work is CPU bound > (2) Made me wonder why I couldn't use the

  1   2   >