Re: OK idea to replace conj and cons with "prepend" and "append" macros that have consistent behavior and return same types as args?

2018-07-22 Thread James Reeves
why there are lists and vectors when they behave in the same way. Then you'd have the same problem, except worse, as you'd also need to explain that "comb" is just a crutch that shouldn't be used outside of the classroom. -- James Reeves booleanknot.com -- You

Re: Using dynamically loaded namespaces like plug-ins

2018-07-29 Thread James Reeves
d 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

Re: How to escape a space in a keyword?

2018-08-09 Thread James Reeves
If Clojure lacks a type that exactly matches ION's symbol type, why not add your own type with a record, then add a data reader for it. For example: #ion/symbol "foo" On Thu, 9 Aug 2018, 05:48 Didier, wrote: > Thanks Andy, ya I actually realized this, I'm using a custom reader > literal now ins

Re: Clojure(Script) web apps in 2018

2018-09-24 Thread James Reeves
ps.google.com/d/optout. >>> >> -- >> - sent from my mobile >> >> -- >> 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 >> No

Re: Keyword namespacing best practices

2018-10-01 Thread James Reeves
ou 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. > -- James Reeves booleankn

Re: Mail queue thread

2018-10-25 Thread James Reeves
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/cloj

Re: Mail queue thread

2018-10-25 Thread James Reeves
; to guard against that. > > Thanks, > Brjánn > > On Thu, 25 Oct 2018 at 18:57, James Reeves wrote: > >> Hi Brjánn, >> >> Executing queued jobs in a background thread is a common task, and as it >> happens there's a set of Java classes to do just that.

Re: Mail queue thread

2018-10-25 Thread James Reeves
r under, and then make it configurable from an environment variable or system property. That way you can tune the service without changing the code. (def mail-pool-size (Integer/parseInt (or (System/getenv "MAIL_POOL_SIZE") "32"))) -- James Reeves booleanknot.com -- You rec

Re: Mail queue thread

2018-10-25 Thread James Reeves
pool 0)(send-email unimportant-mail))] (prn @result1) (prn @result2)) Which is probably easier than messing around with the executor classes directly. -- James Reeves booleanknot.com -- You received this message because you are subscribed to the Google Groups "Clojure" group. T

Re: Mail queue thread

2018-10-26 Thread James Reeves
, and what's your reasoning for not handling it in your "send-email!" function? -- James Reeves booleanknot.com -- 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

Re: Mail queue thread

2018-10-27 Thread James Reeves
t; are interested in the status (no use case yet), it would be easy to just > add more return channels to the email. Does this also seem over-enginereed > compared to just returning the future from the worker and letting it bubble > up to however is interested? > > Thanks

Re: What's the end goal for tools.deps?

2018-11-04 Thread James Reeves
7;s a case of Leiningen not being "official", but that it's design isn't quite in the direction the core devs want to head toward. -- James Reeves booleanknot.com -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: [ANN] Clojure 1.10 has been released!

2018-12-17 Thread James Reeves
e.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,

Re: What do Clojure developers use for recurring functions, other than at-at

2018-12-17 Thread James Reeves
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, visi

Re: Custom vectors/maps and sequence functions

2019-01-15 Thread James Reeves
on of IPersistentCollection and where xform is your transducer. So for example: (into (empty table) (comp (filter process?) (map process)) table) -- James Reeves booleanknot.com -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: Any way to replace function body?

2019-01-19 Thread James Reeves
gle.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 optio

Re: How should I debug a poorly performing small web app, using Jetty?

2019-01-19 Thread James Reeves
t > 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...@goog

Re: transducer parallelism

2019-01-25 Thread James Reeves
re+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- James Reeves booleanknot.com -- 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

Re: undocumented one-argument call of reducer

2019-01-25 Thread James Reeves
ribed 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. > -- James Reeves booleanknot.com --

Re: Noob question on the --> macro implementation

2019-01-26 Thread James Reeves
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

Re: The magic of Lisps

2019-04-28 Thread James Reeves
s.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. >

Re: Keys in EDN maps: keywords or symbols

2019-10-24 Thread James Reeves
le.com/d/msgid/clojure/b4c1d021-a624-482b-9e75-fa5c08057a42%40googlegroups.com > <https://groups.google.com/d/msgid/clojure/b4c1d021-a624-482b-9e75-fa5c08057a42%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- James Reeves booleanknot.com -- You received this mes

Re: Keys in EDN maps: keywords or symbols

2019-10-24 Thread James Reeves
ond itself, then it should be a keyword. Contrast that to a symbol like: clojure.core/conj We know that symbol identifies a clojure function. Even outside of a map, it has an external identity. -- James Reeves booleanknot.com -- You received this message because you are subscribed to t

Re: Keys in EDN maps: keywords or symbols

2019-10-25 Thread James Reeves
t; "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/clojure/68a3fce8-b63a-420b-9fbd-904f911a746b%40googlegro

Re: Bit rot and leiningen?

2020-02-04 Thread James Reeves
ns, 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+unsu

Re: COVID-19 related layoffs

2020-03-18 Thread James Reeves
msgid/clojure/ff7de3a8-744a-4ac8-8ca7-697522fe2ecd%40googlegroups.com > <https://groups.google.com/d/msgid/clojure/ff7de3a8-744a-4ac8-8ca7-697522fe2ecd%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- James Reeves booleanknot.com -- You received this message bec

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

2020-05-13 Thread James Reeves
On Wed, 13 May 2020 at 12:16, Matthew Downey wrote: > The most similar thing you could do to your Java code would be keeping > the token in an atom inside of a connection record. > As a quick note, if you don't need polymorphism, maps should be favoured over records. --

Re: My first Clojure program (and blog post about it)

2015-07-30 Thread James Reeves
One quick suggestion is that arithmetic operations in Clojure frequently take multiple arguments. So: (reduce + [1 2 3]) Is equivalent to: (+ 1 2 3) In terms of style, variables are typically lower-case in Clojure except when referring to a class, interface or protocol. - James On 30

Re: Using a dynamic var for my database connection for implicit connections+transactions

2015-07-30 Thread James Reeves
On 31 July 2015 at 01:44, J. Pablo Fernández wrote: > > I found passing around the database connection to each function that uses > it very error prone when you are using transactions as passing the wrong > one could mean a query runs outside the transaction when in the source code > it is inside

Re: Using a dynamic var for my database connection for implicit connections+transactions

2015-07-31 Thread James Reeves
On 31 July 2015 at 09:54, J. Pablo Fernández wrote: > > For me, the thing is, I have a traditional relational database here, this > is already far from pure. For example, calling (db/create-user " > pup...@pupeno.com") twice will not only not return the same thing the > second time, it'll actually

Re: Changing write output file on the fly

2015-07-31 Thread James Reeves
The way I'd do it is to write a function that caches the output writer or stream. When the cache expires, the function closes the old writer and opens a new one to the new file. In the example below, I'm assuming you have a function that returns the same name for the same hour. (let [cache (volat

Re: Changing write output file on the fly

2015-07-31 Thread James Reeves
On 31 July 2015 at 17:18, Marcin Jurczuk wrote: > > Some reading is required to understand your code (never used volatile!) > but thanks for direction. > I will try this way. > Volatiles were introduced in Clojure 1.7.0, and trade thread-safety for better performance. I could have used an atom fo

Re: Using a dynamic var for my database connection for implicit connections+transactions

2015-08-01 Thread James Reeves
On 1 August 2015 at 01:38, jongwon.choi wrote: > > That's how I normally use dynamic vars. Some people afraid of using it, > but it is like a knife - If you know how to use it, it is useful to remove > unnecessary complexity. > Well, it's more that dynamic vars trade convenience for *greater* com

Re: Metadata

2015-08-05 Thread James Reeves
Metadata is perhaps most frequently used on vars: user=> (meta #'comp) {:arglists ([] [f] [f g] [f g & fs]), :doc "Takes a set of functions and returns a fn that is the composition\n of those fns. The returned fn takes a variable number of args,\n applies the rightmost of fns to the args, the

Re: Using a dynamic var for my database connection for implicit connections+transactions

2015-08-05 Thread James Reeves
On 5 August 2015 at 14:03, Dmitri wrote: > What I'm talking about is whether it's a better pattern to leave a > repetitive and error prone task to the user or encapsulate it in a single > place. The whole discussion boils down to following options. > > The first option is that we keep functions p

Re: Using a dynamic var for my database connection for implicit connections+transactions

2015-08-05 Thread James Reeves
On 5 August 2015 at 18:04, Dmitri wrote: > I agree that wrapping the functions is a sensible approach. Using > wrap-transaction is precisely how I ended up doing it with the conman yesql > wrapper https://github.com/luminus-framework/conman > > The approach I took there is to have the generated f

Re: Clojure, WEB and Enterprise development

2015-08-05 Thread James Reeves
On 5 August 2015 at 22:28, Olek wrote: > Problem: there is no a bind for the JEE servers - they should be treated > as the SQL - you will never reach its maturity > > Solution: so you should parasite it and make a wrapper around timed > services, jms queues, web services, ejb, jpa (with changed s

Re: no set-car! in clojure

2015-08-06 Thread James Reeves
As with all Clojure data structures, lists in Clojure are immutable, so they cannot be modified in place. Also, defs in Clojure are always global to the current namespace, no matter where they are. For this reason, it's generally not a good idea to nest defns. You may want to refer to how other p

Re: Clojure beyond Java 6 ?

2015-08-07 Thread James Reeves
Java 6 can be thought of as the minimum version of the JVM that Clojure supports. Regarding NIO2, it's worth pointing out that Clojure itself only has minimal wrapping around blocking streams, and nothing for NIO1. Using Java APIs directly in Clojure is not uncommon. Incidentally, java.lang.AutoC

Re: Rabid wild animals in my clojure argument lists, code gets infected.

2015-08-22 Thread James Reeves
https://github.com/roomkey/annotate is another possibility - James On 23 August 2015 at 02:06, Colin Yates wrote: > Hi Dave, it _isn't_ an Illegal argument though :-), your destructuring > is simply ignoring that parameter. > > However, I get the pain and solutions might be (in order of 'heavyn

Re: Rabid wild animals in my clojure argument lists, code gets infected.

2015-08-23 Thread James Reeves
On 23 August 2015 at 15:17, Dave Tenny wrote: > The point of my colorful title and judgmental post is that in the example, > passing :e for the declared parameters as declared is a pointless operation > at best, and in most practical situations it is also an erroneous > operation. > > The languag

Re: :arglists metadata on defmulti/defmethod forms

2015-08-23 Thread James Reeves
I tend to add the metadata in manually when I write multimethods. (defmulti foo "Does some foo to x." {:arglists '([x])} :type) - James On 23 August 2015 at 16:51, Dave Tenny wrote: > defmulti+detmethod doesn't seem to maintain any :arglists metadata with > the Var filled by defmulti. >

Re: Java constructor question

2015-08-23 Thread James Reeves
You could use eval: (defn make-it [class] (eval `(new ~class "abc"))) That's likely to be less performant than using java.lang.reflect.Constructor though. - James On 23 August 2015 at 21:06, Dave Tenny wrote: > Is there a way to parameterize a bit of code that invokes a constructor > withou

Re: [ANN] - New Clojure Instant Answer on DuckDuckGo

2015-08-25 Thread James Reeves
Nice work :) - James On 25 August 2015 at 23:04, Rafik NACCACHE wrote: > Hi Guys, > > I contributed an Instant Answer to DuckDuckGo. > > > When you search for "Clojure" with a number of terms, you directly have > under the "software" tab all the packages matching your query from Clojars. > > En

Re: Homoiconicity in Clojure - the broken promise

2015-08-27 Thread James Reeves
On 27 August 2015 at 10:31, Olek wrote: > > Today I fall into: > > java.lang.RuntimeException: java.lang.ClassFormatError: Invalid method > Code length 88118 in class file xxx$eval304 (xxx.clj:274) (xxx.clj:3) > > problem. > > The reason is that I tried to use data as code and just execute the >

Re: Deploying Lein Template to Clojars

2015-08-27 Thread James Reeves
The "org.clojars.username/project" naming scheme is generally for your own projects, or your own forks, that you're not publicising for general use. For instance, perhaps you have a fork of Compojure, and decide to name it "org.clojars.whamlet/compojure". For Leiningen templates you should use the

Re: How do I print each test name in clojure.test?

2015-09-01 Thread James Reeves
The clojure.test/report multimethod is what you're looking for. You can add a method for the :begin-test-var or :end-test-var types: (defmethod clojure.test/report :begin-test-var [m] (println (-> m :var meta :name))) The report var itself is dynamic, so you can override it that way if you

Re: How do I print each test name in clojure.test?

2015-09-01 Thread James Reeves
On 1 September 2015 at 17:34, Mayank Jain wrote: > > It throws Stackoverflow error > > StackOverflowError >> clojure.lang.Util.equiv (Util.java:33) >> clojure.core/isa? (core.clj:5115) >> clojure.lang.Var.invoke (Var.java:388) >> clojure.lang.MultiFn.isA (MultiFn.java:123) >> clojure.lang.MultiFn.

Re: Stuart Sierra's Component: retries & restarts in production

2015-09-04 Thread James Reeves
On 3 September 2015 at 00:03, wrote: > > The HTTP connection may be closed at any time by the server; if that > happens, the app should persistently attempt to reconnect using an > exponential back-off pattern. In addition, if the app goes thirty seconds > without receiving any data, it should clo

Re: Just found out about Elixirs function argument pattern matching...

2015-09-05 Thread James Reeves
You might want to take a look at defun: https://github.com/killme2008/defun - James On 5 September 2015 at 09:24, Amith George wrote: > Hi, > > I just read a blog post [1] talking about Elixir pattern matching. I was > thoroughly impressed with the way its handled in Elixir. I am posting this >

Re: Just found out about Elixirs function argument pattern matching...

2015-09-06 Thread James Reeves
On 6 September 2015 at 02:31, Timothy Baldridge wrote: > >> Thanks, it helps to know using a tagged vector is a real pattern :) > > I don't know that it's a "real pattern". If I saw code like this in > production I would probably raise quite a stink about it during code > reviews. It's a cute hac

Re: Just found out about Elixirs function argument pattern matching...

2015-09-06 Thread James Reeves
On 6 September 2015 at 14:41, Timothy Baldridge wrote: > >> "Variants fulfil the same purpose as key/value pairs in a map. The key > denotes a context-sensitive purpose for the data, rather than its type." > > Then use a key/value type. That's my problem with this approach, it > abuses a collecti

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread James Reeves
On 6 September 2015 at 15:38, Timothy Baldridge wrote: > >> I'm not sure why you think that it "complicates the code, and makes it > harder to understand". > > Alright, I'll use the phrase: using vectors as variants complects order > with data. If you hand me a vector that says [:name "tim"] I ha

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread James Reeves
On 6 September 2015 at 09:57, Amith George wrote: > > Could you elaborate on what you mean by variants being like a key value > pair? > I mean that tags are usually used to describe what the data *is*, whereas keys are usually used to describe what the data is for. For instance, one might have a

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread James Reeves
On 7 September 2015 at 13:59, James Reeves wrote: > On 6 September 2015 at 15:38, Timothy Baldridge > wrote: >> >> As far as performance goes, this is normally the sort of thing that gets >> baked into an app at a pretty low level, that's why I suggest it should

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread James Reeves
On 7 September 2015 at 15:49, Timothy Baldridge wrote: > > Types are good even in dynamic languages, we should use the more. As > mentioned by Thomas, records are the idiomatic way to store typed > information in Clojure. > I don't think that's true. Or rather, I think it depends on what you mean

Re: add concurrency feature as language spec.

2015-09-07 Thread James Reeves
You mean like core.async? - James On 7 September 2015 at 16:49, Renjith Thankachan wrote: > I have seen clojure now has different platform implementation.It would be > good if its concurrency spec. must be a language style spec. like "go" ing > Golang. > Clojure-CLR,Clojure-Java,Clojurescript n

Re: Just found out about Elixirs function argument pattern matching...

2015-09-08 Thread James Reeves
On 8 September 2015 at 11:38, Thomas Heller wrote: > > If you look at these implementations > > (def OneOff [(s/one s/Str 'name) (s/one s/Str 'email)]) > > (s/defrecord OneOff > [name :- s/Str > email :- s/Str]) > > (defrecord OneOff [name email]) > > All of them do more or less the same

Re: Clojure/Pedestal vs Go

2015-09-13 Thread James Reeves
There's the TechEmpower benchmarks at: https://www.techempower.com/benchmarks Interestingly, Clojure is currently ahead of Go in the single and multiple database query benchmarks. - James On 13 September 2015 at 21:44, Alan Thompson wrote: > Hi, > > I'm about to start a new web project and the

Re: functions that operate on map_entry?

2015-09-25 Thread James Reeves
"key" and "val" might be the functions you want. - James On 25 September 2015 at 21:32, Fenton Travers wrote: > Are there functions that would operate on an map_entry, to give the key > and the value? I image looping over a map and with each entry being able > to get the key of that map_entry

Re: 'seq' performance for 'empty?' compared to 'count'. And where's !=?

2015-10-01 Thread James Reeves
Benchmarking the JVM can be difficult, as it uses a JIT compiler. Your examples tally more or less with my own benchmarks, but for the most accurate results I'd recommend using Criterium and ensuring that the :jvm-opts map in your project file is empty:

Re: Origin for Clojure using the term 'vector' instead of 'array'?

2015-10-02 Thread James Reeves
In a number of languages, arrays are typically a fixed size, whereas vectors are typically a variable size. I imagine Clojure adopts this for the same reason, and also because "array" already refers to Java arrays. - James On 3 October 2015 at 03:49, Daniel Compton wrote: > I recently had some

Re: [ANN] Shrubbery 0.3.0, a stubbing, spying, and mocking library for Clojure protocols

2015-10-05 Thread James Reeves
Very nice. I was looking for something like this. - James On 5 October 2015 at 15:14, Brian Guthrie wrote: > Clojure protocols are a great way to encapsulate operations with side > effects, but suffer from a lack of general test tooling. Shrubbery provides > a small set of basic building blocks

Library suggestions requested for clojure-toolbox.com

2015-10-05 Thread James Reeves
If you've written or know about a Clojure or ClojureScript library, and it's not already on clojure-toolbox.com , I'd like to hear about it. Post the name and URL (and an optional category) as reply to this message, and I'll add it to the site. - James -- You rec

Re: Library suggestions requested for clojure-toolbox.com

2015-10-05 Thread James Reeves
On 6 October 2015 at 01:15, William la Forge wrote: > {:name "aatree", > :URL "https://github.com/laforge49/aatree";, > :category "Data Structures"} > Where is this library deployed to? I can't see it on Clojars and there aren't any other Maven repositories listed in the project file or README

Re: Ted Dziuba: The S in REST

2015-10-13 Thread James Reeves
On 13 October 2015 at 09:49, Patrick Kristiansen wrote: > > Has anyone read and given any thoughts to the ideas about immutability and > REST by Ted Dizuba here: > > http://teddziuba.github.io/2014/08/18/the-s-in-rest/ > > Has anyone done anything resembling this? I think the ideas sounds > intrig

Re: Newbie trying HTML parsing

2015-10-14 Thread James Reeves
In the clj-tagsoup example it has the following line: (use 'pl.danieljanus.tagsoup) The use function is like require, except it aliases the vars to the current namespace. So the pl.danieljanus.tagsoup is the namespace to use. If the README doesn't provide any clues, you can sometimes figure

Re: Newbie trying HTML parsing

2015-10-14 Thread James Reeves
Will using *clj-tagsoup* or > *Crouton > *make this location operation easier? Perhaps even using *Enlive *might > make it easier, since the location and path to the tag is not known; it > must be located. > > On Wednesday, October 14, 2015 at 1:53:11 PM UTC-5, James Reev

Re: Newbie trying HTML parsing

2015-10-14 Thread James Reeves
It looks like the response body is a string rather than a stream. Try using crouton.html/parse-string instead. - James On 15 October 2015 at 01:27, Mike wrote: > So now I'm trying to make the conversion to Crouton. Of course that is > not going well. Here is a chunk of code: > > (ns one.core

Re: Newbie trying HTML parsing

2015-10-15 Thread James Reeves
On 15 October 2015 at 18:00, Mike wrote: (dzx/xml1-> my-zipper dz/descendants) > > gives me what appears to be the original zipper structure, which I wasn't > expecting. I was expecting a flattened-out seq of the nodes. > The dz/descendants function doesn't return a seq of nodes, but a seq of z

Re: Calling object members with symbols

2015-10-18 Thread James Reeves
On 18 October 2015 at 23:54, Timur wrote: > Hi all, > > Is there anyway to call an object member using its symbol? > > For instance we have an object o, we get the symbol of a method, e.g., > toString, of our object o using clojure.reflect/reflect and and I want to > execute this method on this o

Re: compojure/http-kit redirection

2015-10-26 Thread James Reeves
On 26 October 2015 at 20:47, JvJ wrote: > I would like to have one request redirect to another page, but I'm not > sure how: > > (defroutes app > (GET "/ws" ws-handler) ; Websocket connection > (GET "/user/:id" [id] ;; I want to redirect to index.html?user=id >)) > > When I get the /u

Re: Style, Efficiency, and updating nested structure

2015-11-11 Thread James Reeves
In general, it's not helpful to reach for optimisations like mutability without a benchmarking tool to tell you how much of a difference you're making. I'd be tempted to write something like: (defn find-project-index [projects id] (first (keep-indexed (fn [i p] (if (= (:project_id p) id) i)

Re: help with clojure

2015-11-14 Thread James Reeves
When thinking about trees, I find it's often best to start with the most basic case. So in your case, begin by writing a function that deals with a single operator and two numerical arguments: (f '(* 4 9)) => (36 4 9) (f '(- 6 10)) => (-4 6 10) Next, consider the case where you have two p

Re: help with clojure

2015-11-14 Thread James Reeves
So start with something like: (def a '(+ 3 9)) Then write a function where: (evaltree a) => (12 3 9) Don't worry about recursion to start with. Just get the simplest case working first. - James On 14 November 2015 at 17:46, wrote: > Sorry I'm a complete rookie at this that didn'

Re: help with clojure

2015-11-14 Thread James Reeves
Okay, so: (defn evaltree [tree] (cons (eval tree) (rest tree))) That evaluates the tree, assuming that (rest tree) only contains numbers. (eval-tree '(+ 3 9)) However, we also want to evaluate the arguments in the same way. The arguments are a list, and when we want to do somethin

Re: Clojure Objects

2015-11-20 Thread James Reeves
What's the benefit to writing code like this? The only thing I could possibly see as being considered an advantage is that it encapsulates the file channel, but you've exposed that via a key anyway. - James On 21 November 2015 at 02:54, William la Forge wrote: > Code as data is the mantra. Fun

Re: Clojure Objects

2015-11-21 Thread James Reeves
On 21 November 2015 at 04:50, William la Forge wrote: > > The reason for having this "type of object" at all is that I was going to > have 3 copies of the same code. Which I find to be a bad thing. > Could you explain why you were going to have duplicate code, and how your object system solved th

Re: Ultralight Components

2015-11-23 Thread James Reeves
Just to be clear, by "mixin" you're referring to merging two maps of functions? Have you considered using composition instead of mixins? - James On 23 November 2015 at 20:01, William la Forge wrote: > When an object is built from a map, aggregating mixins is a trivial > operation. But when a m

Re: Ultralight Components

2015-11-23 Thread James Reeves
ng up with good terms. I very much appreciate your help > here James. > > --b > > On Monday, November 23, 2015 at 6:50:21 PM UTC-5, James Reeves wrote: >> >> Just to be clear, by "mixin" you're referring to merging two maps of >> functions? >> >

Re: Ultralight Components

2015-11-23 Thread James Reeves
I feel you might be barking up the wrong tree with this approach, as it seems to complicate things without providing any compelling advantages. That said, if it's fun then by all means continue to experiment. Maybe I'm wrong :) - James On 24 November 2015 at 02:45, William la Forge wrote: > I

Re: Ultralight Components

2015-11-23 Thread James Reeves
elpful and also a genuine delight. > > --b > > On Mon, Nov 23, 2015 at 10:08 PM, James Reeves > wrote: > >> I feel you might be barking up the wrong tree with this approach, as it >> seems to complicate things without providing any compelling advantages. >> >>

Re: Ultralight Components

2015-11-24 Thread James Reeves
On 24 November 2015 at 13:48, William la Forge wrote: > James, thanks for recommending Simple Made Easy > . As usual, I > strongly agree with 95% or more of everything Rich says. > > While listening to this talk, I kept thinking about why I am

Re: [ANN] 2015 State of Clojure Community survey

2015-12-04 Thread James Reeves
What does this question mean, exactly? 6. What types of applications do you use Clojure, ClojureScript, or > ClojureCLR in? > > Company-wide/Enterprise > Departmental > Team > Personal - James On 4 December 2015 at 16:31, Alex Miller wrote: > If you are a user of Clojure, ClojureScript, or Cl

Re: Naming convention for atoms, refs, etc.?

2015-12-05 Thread James Reeves
Why should they have any sort of naming scheme? Dynamic vars are unusual because their values can change. Atoms and refs remain the same, and even though inside their values mutate, they don't affect the outer var. - James On 5 December 2015 at 21:39, Mars0i wrote: > Does anyone want to suggest

Re: [ANN] 2015 State of Clojure Community survey

2015-12-06 Thread James Reeves
Clojure app?" >> >> On Friday, December 4, 2015 at 3:33:10 PM UTC-5, puzzler wrote: >>> >>> I took it to mean "How many people are working on your Clojure project?" >>> >>> On Fri, Dec 4, 2015 at 8:44 AM, James Reeves >&g

Re: What exactly is a form in Clojure?

2015-12-28 Thread James Reeves
A form is a complete piece of data the reader can consume. So "1", "a", "[x y]" and "(foo (bar baz))" are all forms, since they can be read as complete (unevaluated) data structures. On the other hand, "(foo" is not a form as it is not complete, and "(foo) (bar)" is two forms, because each part is

Re: Project structure when using reader conditionals

2015-12-30 Thread James Reeves
My directory structure looks like: src/foo/client/bar.cljs src/foo/common/bar.cljc src/foo/server/bar.clj So I divide code by purpose, but they're all in the same source directory. - James On 30 December 2015 at 00:56, Alan Moore wrote: > Yes it would be handy for small projects b

Re: Parsing complex parameter lists

2016-01-18 Thread James Reeves
Take a look at the name-with-attributes function in tools.macro . - James On 19 January 2016 at 02:20, JvJ wrote: > I'm extending def macros, and I would like to know if there is an easy way > to handle parsing the complex parameter lists that can be pass

Re: Check if value is a ring handler

2016-01-27 Thread James Reeves
On 27 January 2016 at 05:42, JvJ wrote: > Is there a way to dynamically check whether or not a given function > qualifies as a ring handler? > Nope. Clojure isn't statically typed, so you can't determine that a function always returns a value of a particular type. - James -- You received this

Re: Power function

2016-02-01 Thread James Reeves
What power function do you mean? - James On 2 February 2016 at 03:02, Karl Brodowsky wrote: > I think that since it is agreed in many circumstances that 0^0 is 1, I > would make that the default... > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" gr

Re: Kicking off a process in Compojure Defroutes / http-kit runserver

2016-02-01 Thread James Reeves
Why can't you just start your background threads, then start your server? - James On 1 February 2016 at 23:03, JvJ wrote: > I'm working on a web app, and I'm using defroutes to define my application > and runserver to initialize it. However, when run-server is called, I > can't find a way to r

Re: Can the data in a vector have data inside it that points to the same vector? vector1=[a b c d] a=[1 2 f s vector1]

2016-02-09 Thread James Reeves
No, vectors can't be recursive. However you can use a reference of some description, e.g. (let [p (promise), v [p]] (deliver p v) v)) You could also use a lazy seq. - James On 10 February 2016 at 04:29, Timothy Vinick wrote: > Here's an example: > > vector1=[a b c d] a=[1 2 f s

Re: Reduce + merge-with error on lazy sequence of maps

2016-02-11 Thread James Reeves
There are a couple of errors in your code: 1. You have no initial value for the reduce, yet your output seems different to your input 2. prioritized-courses returns a seq, but merge-demand expects a map My guess is that you only get the error when you hit data in your input sequence with the same

Trouble replacing deprecated map< function

2016-02-12 Thread James Reeves
I currently have some core.async code that looks like: (map< :foo ch) However, map< and map> are now deprecated, with the suggestion to use transducers instead. Unfortunately it's not obvious how to go about that. At first I thought that I could use a pipe and a new channel: (pipe ch (c

Re: No eval in ClojureScript!?

2016-02-13 Thread James Reeves
ClojureScript has cljs.js/eval, which while not as convenient as clojure.core/eval, can accomplish the same effect. The reason why ClojureScript doesn't have a standard eval is because it adds a huge amount of overhead for relatively little gain. You need to load the entire ClojureScript compiler

Re: No eval in ClojureScript!?

2016-02-13 Thread James Reeves
While eval is an important part of Clojure, it's also very rarely used. I've been working with Clojure for almost eight years now, and I've written 60 Clojure libraries. Despite that, I've used eval less than half a dozen times. Having a way of evaluating ClojureScript in ClojureScript is a nice m

Re: No eval in ClojureScript!?

2016-02-13 Thread James Reeves
On 13 February 2016 at 17:11, ru wrote: > First thing that comes to my mind is MAXIMA Computer Algebra Program from > LISP ecosystem. That is a system for the manipulation of symbolic and > numerical expressions, including differentiation, integration and many > other useful things. It will be n

Re: No eval in ClojureScript!?

2016-02-13 Thread James Reeves
On 13 February 2016 at 18:58, ru wrote: > I think macros can't be of much help in my task. I am working on project > rete4frame (https://github.com/rururu/rete4frames) and now want to port > it to ClojureScript. It is CLIPS-like expert system shell with simplified > version of RETE algorithm. It

Re: Shouldn't we consider this a bug? "Unable to resolve symbol: % in this context"?

2016-02-14 Thread James Reeves
The problem is: how do you tell the difference between a pre- and post-condition map, and a map you want to return from the function? The only way to do it is to explicitly return nil. - James On 15 February 2016 at 04:48, Laws wrote: > If I write this in a file: > > (defn different-order [ord

<    1   2   3   4   5   6   7   8   9   10   >