Re: symbol is not a symbol in (def (symbol "x") ...) ???

2020-10-05 Thread Peter Hull
On Friday, 2 October 2020 at 20:38:50 UTC+1 Bost wrote: > I have a problem with `def` in macros. I'd like to create a bunch of > following definitions: > > Also possible to do without macros: (defn def-stuff [xs] (for [x xs] (intern *ns* (symbol x) (upper-case x This seems to work for me, if

Re: Using :clojure.spec.alpha/invalid inside clojure.core macros throw exception

2019-09-18 Thread Peter Hull
On Wednesday, 18 September 2019 20:48:39 UTC+1, David Bürgin wrote: > > This is a known issue, see > https://clojure.atlassian.net/projects/CLJ/issues/CLJ-1966 > 2016! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send ema

Re: Using :clojure.spec.alpha/invalid inside clojure.core macros throw exception

2019-09-18 Thread Peter Hull
On Tuesday, 17 September 2019 22:34:04 UTC+1, Daniel Dinnyes wrote: > > (let [x 42] :clojure.spec.alpha/invalid) > > That's an interesting one. It's failing the spec on the let's body, which is just 'any?' , so this is initially surprising. However s/valid? is implemented as, approximately, (no

Re: questionable result of Clojure code execution in org babel

2019-08-12 Thread Peter Hull
On Monday, 12 August 2019 18:47:48 UTC+1, Alex Miller wrote: > > You can’t wrap ns and forms into a single do like that. If you google > around you can find this issue referred to as the Gilardi scenario. OK, thanks, Alex. Is this not covered in https://technomancy.us/143 by the para that starts

Re: questionable result of Clojure code execution in org babel

2019-08-12 Thread Peter Hull
On Friday, 9 August 2019 11:52:32 UTC+1, Johannes wrote: > > I posted the problem there. > Not a great response so far, I see! I had another little play and it may be possible to solve by a small change to ob-clojure.el. Basically we just wrap the forms and the ns into a single (do ...) form.

Re: questionable result of Clojure code execution in org babel

2019-08-08 Thread Peter Hull
On Thursday, 8 August 2019 17:00:43 UTC+1, Johannes wrote: > > Thank you, Pete, for your investigation. > OK, I would be interested to hear if you get this sorted out! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send emai

Re: questionable result of Clojure code execution in org babel

2019-08-07 Thread Peter Hull
On Wednesday, 7 August 2019 12:42:07 UTC+1, Peter Hull wrote: The connection returns two values, first 'nil' then '24', and function nrepl--merge concats these into the incorrect response that org-mode pastes into your doc. Wait, might be on to something here. In org

Re: questionable result of Clojure code execution in org babel

2019-08-07 Thread Peter Hull
I poked around at this a bit. If you enable nrepl's logging (use nrepl-toggle-message-logging) you will see something like this: (--> id "18" op "eval" session"86281560-e467-47c4-869d-043b03f5c546" time-stamp "2019-08-07 12:23:33.769213028" code "(ns org-babel-c

Re: questionable result of Clojure code execution in org babel

2019-08-06 Thread Peter Hull
On Monday, 5 August 2019 17:12:41 UTC+1, Johannes wrote: > > What is going wrong? > I tried Emacs 'built-in' org mode (9.1.9) and it gave the correct result, I then installed 9.2.5 and that did give the incorrect result that you reported. So, I assume something changed in org-mode between 9.1.9 a

Re: Compiler error message misses the target

2019-05-08 Thread Peter Hull
I tried just with the output of 'lein new app' - put an extra 'd' somewhere at the top level in core.clj, say below (defn- main ...), and then 'lein run' will give a strange location for the error (e.g. line 1 column 113) Is the same as what Alan is reporting? On Wednesday, 8 May 2019 12:24:23 U

Re: [ANN] Clojure 1.10.0-alpha7

2018-09-06 Thread Peter Hull
On Thursday, 6 September 2018 19:11:14 UTC+1, Andy Fingerhut wrote: > > Doing a little bit more digging, I just did a Google search for: > > clojure "expects more than one argument" > > Nice one, thanks. I did a similar search but didn't find that - instead a repo called "venantius/ultra" which ha

Re: [ANN] Clojure 1.10.0-alpha7

2018-09-06 Thread Peter Hull
On Thursday, 6 September 2018 15:09:15 UTC+1, Andy Fingerhut wrote: > > > If you have a few minutes to try out the tests in my repo to see if you > get different results than I did, I'd be curious to hear if your results > are different. I'd be more curious to learn of a way to write a unit tes

Re: [ANN] Clojure 1.10.0-alpha7

2018-09-06 Thread Peter Hull
On Wednesday, 5 September 2018 13:39:36 UTC+1, stuart@gmail.com wrote: > > 1.10.0-alpha7 includes the following changes since 1.10.0-alpha6: > I was pleased to see that going from alpha 6 to 7 found an error in one of my tests. I had something like (is (= (x (func y and the new version re

Re: Atom/Clojure N00b - dependency issue

2018-07-28 Thread Peter Hull
On Saturday, 28 July 2018 13:21:14 UTC+1, Nando Breiter wrote: > > I've installed proto-repl as a package within Atom, and it works. I've > never listed it as a dependency within a project. > It's in the docs (https://atom.io/packages/proto-repl) under Dependencies: Add a dependency to the Cloj

Re: clojure test has 10 failures

2018-07-24 Thread Peter Hull
On Tuesday, 24 July 2018 05:53:03 UTC+1, 冯忠孝 wrote: > > [java] Ran 635 tests containing 17442 assertions. > [java] 10 failures, 0 errors. > > I see Throwable->map is involved in all of these; but I can't see how it could give the results it seems to here. If you do (Throwable->map (Excep

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

2018-05-21 Thread Peter Hull
On Monday, 21 May 2018 20:22:21 UTC+1, Andy Fingerhut wrote: > > Is there some other command you would recommend to force reinstall of > ca-certs that might work? > > Specifically on the ca-certs thing, there is a bug filed with Ubuntu, and it looks like it should be fixed fairly soon; https://bu

Re: Is the vector a sequence?

2018-04-28 Thread Peter Hull
On Friday, 20 April 2018 22:39:41 UTC+1, Rick Moynihan wrote: > > It's also worth mentioning vectors are sequential: > I'd be interested to know what is the purpose of sequential. The docs for sequential? just say it implements Sequential, and c

Re: Clojure Group

2018-04-16 Thread Peter Hull
What was the question? I am on tenterhooks now... -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. T

Re: The Reasoned Schemer chpt 4: "Please pass the aspirin"

2018-02-25 Thread Peter Hull
On Sunday, 25 February 2018 17:46:26 UTC, Calvin Sauer wrote: > > I'm currently struggling with the same question. Did you ever happen to > reach a satisfying conclusion? > https://groups.google.com/forum/#!topic/minikanren/JCKJV7k7lGU -- You received this message because you are subscribed to

Re: Problem with lazy seqs in macros

2018-02-05 Thread Peter Hull
You could (I think) simplify to: (defmacro hmap [& kvs] "Returns an immutable hashmap. Keys must be compile-time constants." (if (even? (count kvs)) (let [keys (into [] (take-nth 2) kvs)] `(fn [k#] (case k# ~@kvs ::keys ~keys))) (throw (Exception. "hmap takes an EVEN n

Re: Problem with lazy seqs in macros

2018-02-05 Thread Peter Hull
On Monday, 5 February 2018 09:22:58 UTC, Divyansh Prakash wrote: You see what's happening with macroexpand (macroexpand '(hmap :a 1 :b 2)) (fn* ([k__4009__auto__] (clojure.core/case k__4009__auto__ :a 1 :b 2 :user/keys [:a :b]))) versus (fn* ([k__4146__auto__] (clojure.core/case k__4146__aut

Re: Cider - emacs lisp errors reported

2017-12-10 Thread Peter Hull
On Sunday, 10 December 2017 14:14:05 UTC, Bozhidar Batsov wrote: > > It might have been changed upstream. Not sure what's your Emacs version. A > while ago we backported this macro in whatever its current form was for > compatibility with older Emacsen. > > File a ticket on GitHub and we'll inves

Cider - emacs lisp errors reported

2017-12-10 Thread Peter Hull
I noticed this when updating cider via melpa, and I wasn't sure if it's already known about or whether it is even an problem. I thought I'd ask here before submitting an issue to github. Compiling file /Users/peterhull/.emacs.d/elpa/cider-20171209.1602/cider-browse-spec.el at Sun Dec 10 11:29:

Re: spec for an agent

2017-11-17 Thread Peter Hull
On Friday, 17 November 2017 16:53:57 UTC, Didier wrote: > > Why do you return an agent from a function? Can't you just return the map > it conatains instead? And spec that? I want to write a function spec (s/fdef) for a function make-agent that takes some initialisers and returns a new agent wi

spec for an agent

2017-11-17 Thread Peter Hull
I am using agents whose state is a map. I have a spec for this map, ::agent-state. What's the best way to validate the agent? I have: (s/valid? #(s/valid? ::agent-state (deref %)) myagent) Is this there a neater way to do this? (I actually want the spec to apply to the ret value of an s/fdef)

Re: clojure.data.xml with newline / return in attribute values

2017-11-09 Thread Peter Hull
On Thursday, 9 November 2017 11:21:36 UTC, Jochen wrote: > > hmmm, that is unfortunately not the reality. In fact any newlines/returns > in attributes are collapsed to a single space (saw mentioned somewhere that > this is officially so). > It's 'attribute value normalisation' - see https://www

Re: [ANN] Clojure 1.9.0-beta4

2017-11-02 Thread Peter Hull
On Thursday, 2 November 2017 19:46:35 UTC, Alex Miller wrote: > > I think this is an issue with Leiningen with Java 1.9 (re things in > dynapath and the changes in classloader details in Java 1.9), and not > Clojure itself. > > Yes this was leiningen issue #2331 now fixed: https://github.com/tec

Re: Is there a better way to get to `Classname[].class` ?

2017-10-10 Thread Peter Hull
I actually preferred your solution, pericles, because it doesn't require memorising the "[L...;" syntax, and works if you don't know the class at compile time. By the way you can use make-array to create a zero size array which might be (ever so slightly) more efficient. For reference (apologie

Re: The performance of plain map vs. defrecord

2017-10-09 Thread Peter Hull
Slightly off-topic, but why doesn't using the 'incorrect' alphabet-macro give an error? If I try and define a Record with keyword keys it tells me very clearly not to: user=> (defrecord Wrong [:a]) CompilerException java.lang.AssertionError: defrecord and deftype fields must be symbols, user.W

Re: How to properly spec this simple structure

2017-10-05 Thread Peter Hull
I will just point out that, in the suggested answer, (gen/return (make-channel)) calls make-channel once, and creates a generator whose output is that same object repeatedly, not a new instance of the class each time. That may not matter, but it's not what (I think) you intended in your original

Re: How to properly spec this simple structure

2017-10-05 Thread Peter Hull
On Thursday, 5 October 2017 20:52:10 UTC+1, Alex Bezhan wrote: > > Can someone explain what I've done wrong and how to do it the right way? As I understand it, you will need to code the generator equivalent of (repeatedly make-channel) but I don't know how to do that, sorry. Then I think you ju

Re: How to properly spec this simple structure

2017-10-05 Thread Peter Hull
On Thursday, 5 October 2017 19:52:47 UTC+1, Alex Bezhan wrote: > > > > (s/def ::channel (s/spec (::channel-type) > :gen channel-gen)) > > Don't think it's the answer, but should ::channel-type be in parens here? -- You received this message because you are subscribed to

spec for a multi-arity function

2017-10-05 Thread Peter Hull
Is there any guidance on how to do the fdef for a function with more than one arity? As an example, this one which takes one or two arguments: (defn report "Report an error code, optionally with a message" ([errno] ...) ([errno msg] ...)) Could be: (s/fdef report :args (s/alt :brie

Re: Reading file to list as char array

2017-10-03 Thread Peter Hull
On Tuesday, 3 October 2017 12:39:47 UTC+1, Furkan Yıldız wrote: > > I am reading a txt file containing words. I need to add these words to the > list as char. For example > > > > I think you need to split into words first using a regex then seq each word (def words (clojure.string/split allstri

Re: [core.spec] Stricter map validations?

2017-10-03 Thread Peter Hull
I have found, as an application evolves, some extra data is required which comes from elsewhere. For example, I have an application where data is read from a network socket, transformed and stored. For auditing, I later decided it was useful to capture the remote address from the socket right

Re: read-line is limited to 4095 chars

2017-09-28 Thread Peter Hull
On Tuesday, 26 September 2017 12:28:26 UTC+1, baptiste...@oscaro.com wrote: > > I was using read-line to read a large line and found it limits its input > to 4095 chars. I tested this on both Clojure 1.8.0 and 1.9.0-beta1. > > I tested this on Windows. I found that piping from the CMD.EXE command

Re: transducers and eduction

2017-09-05 Thread Peter Hull
On Tuesday, 5 September 2017 12:11:04 UTC+1, Christophe Grand wrote: > > > Hope this helps. > That is very helpful to me. It would be great if those tips could be added to the official documentation. Pete -- You received this message because you are subscribed to the Google Groups "Clojure" gr

Re: transducers and eduction

2017-09-05 Thread Peter Hull
On Tuesday, 5 September 2017 00:07:07 UTC+1, Alex Miller wrote: > > When you say "the" answer here, that doesn't make sense to me. > Nor me. But, I think I've got it now, thanks for your help. The question I should have asked was "what is the purpose of the ([x] ...) arity in an eduction?" I wi

transducers and eduction

2017-09-04 Thread Peter Hull
I am trying to understand transducers and am reading through https://clojure.org/reference/transducers I think I am missing something, please can someone help? I read the part about the 'shape' of a transducer-creating-function ( https://clojure.org/reference/transducers#_creating_transducers) a

Re: spec/conform: + vs * differ sometimes, not sure why

2017-08-10 Thread Peter Hull
> On Sunday, July 30, 2017 at 6:55:04 AM UTC-6, Alex Miller wrote: >> >> This is a bug, similar to https://dev.clojure.org/jira/browse/CLJ-2105 >> and http://dev.clojure.org/jira/browse/CLJ-2003. I've spent a little >> time on it but have not figured out the exact problem. If you'd like to >>

Re: "GC overhead limit exceeded": Deceptive message?

2017-08-08 Thread Peter Hull
On Tuesday, 8 August 2017 06:20:56 UTC+1, Nathan Smutz wrote: > Does this message sometimes present because the non-garbage data is > getting too big? > Yes, it's when most of your heap is non-garbage, so the GC has to keep running but doesn't succeed in freeing much memory each time. See http

Re: Converting json to work with clojure.spec

2017-08-07 Thread Peter Hull
On Sunday, 4 December 2016 15:11:55 UTC, Jonathon McKitrick wrote: > > That being said, I see the benefits in moving to namespace qualified keys. > Currently, I'm returning structures directly in Compojure handlers, and the > JSON conversion is implicitly handled. I checked Cheshire and didn't

Re: Unnamed Types - What Am I Doing Wrong?

2017-07-26 Thread Peter Hull
On Wednesday, 26 July 2017 03:03:45 UTC+1, Daniel Compton wrote: > For something like an account, a more idiomatic way to model this in > Clojure might be with maps: > > If I understand Kevin's post correctly, he's already planning to replace his vectors with maps, and he is asking if there's a

Re: Bizzarre cond-> behavior

2017-07-21 Thread Peter Hull
That was quick! So, if I understand it, the problem is not with cond->, it's the chain of let-bindings it expands to? Pete -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts

Re: Bizzarre cond-> behavior

2017-07-21 Thread Peter Hull
On Friday, 21 July 2017 00:35:00 UTC+1, Milt Reder wrote: > > Here's a simplified example: > > I can confirm that pasting that defn into a CIDER repl does take a long time before the prompt comes back. I tried doing a "macro expand all" and it was pretty much instantaneous. The resulting expansio

Re: error in nrepl

2017-06-23 Thread Peter Hull
On Friday, 23 June 2017 23:14:55 UTC+1, lawrence...@gmail.com wrote: > > > I'm curious if folks think it is easier to work with Emacs on a Linux > machine, or on a Mac? > > I use Emacs on Mac, Linux and Windows. I disagree that it's more difficult to use on the Mac vs Linux. On Windows I get my

Re: Use of s/keys with 'and' , 'or'

2017-06-22 Thread Peter Hull
On Thursday, 22 June 2017 11:17:33 UTC+1, Peter Hull wrote: > > That's interesting. Is there anything I can help with to get that patch > accepted? I couldn't get it to apply to the current code in > https://github.com/clojure/spec.alpha because the filenames have changed,

Re: Use of s/keys with 'and' , 'or'

2017-06-22 Thread Peter Hull
On Wednesday, 21 June 2017 16:30:33 UTC+1, Alex Miller wrote: > > Yes, that's actually something that we have a pending patch to correct at > https://dev.clojure.org/jira/browse/CLJ-2046 > That's interesting. Is there anything I can help with to get that patch accepted? I couldn't get it to apply

Re: Use of s/keys with 'and' , 'or'

2017-06-21 Thread Peter Hull
On Wednesday, 21 June 2017 14:33:02 UTC+1, Alex Miller wrote: > > This is correct. This is or, not xor. Oops. OK. It's been one of those days. But, am I correct to say that gen/generate only ever makes values where all the 'or' alternatives are present? i.e. they always conform to: (s/keys :req

Use of s/keys with 'and' , 'or'

2017-06-21 Thread Peter Hull
According to the docs it's possible to use 'and' and 'or' for the required keywords. The example given is: (s/keys :req [::x ::y (or ::secret (and ::user ::pwd))] :opt [::z]) I assume this means the conf

Re: [ANN] Eastwood, the Clojure lint tool, version 0.2.4 released

2017-06-02 Thread Peter Hull
On Thursday, 1 June 2017 22:49:56 UTC+1, Andy Fingerhut wrote: > > I do not know whether you (Peter) are the same as the user pedro-w on > Github, > Indeed I am the same. I've suggested something on the GH issue which is just a hack but may be helpful. I hope you'll appreciate that, coming to i

Re: [ANN] Eastwood, the Clojure lint tool, version 0.2.4 released

2017-06-01 Thread Peter Hull
n* such that tools.reader could pick it up. I am now at the limits of my clojur e knowledge! Does this sound reasonable? Any ideas what I am doing wrong? Pete On Thursday, 1 June 2017 07:19:04 UTC+1, Peter Hull wrote: > > On Thursday, 1 June 2017 06:55:52 UTC+1, Andy Fingerhut wrote: >

Re: [ANN] Eastwood, the Clojure lint tool, version 0.2.4 released

2017-05-31 Thread Peter Hull
On Thursday, 1 June 2017 06:55:52 UTC+1, Andy Fingerhut wrote: > > Sounds like a limitation/bug in the current Eastwood implementation that > it doesn't handle this. You are welcome to file an issue on Github: > https://github.com/jonase/eastwood/issues > > Thanks for getting back to me. I've fi

Re: [ANN] Eastwood, the Clojure lint tool, version 0.2.4 released

2017-05-31 Thread Peter Hull
On Monday, 22 May 2017 01:51:32 UTC+1, David Cook wrote: > > Eastwood, the Clojure lint tool, version 0.2.4 has been released. See > install instructions and complete documentation at [1]. > Hi David and others, I tried this for the first time on my code and it found some errors (hooray!) but al

Re: Learning clojure - comments on my function?

2011-09-29 Thread Peter Hull
Thank you, both! I guessed there would be a neater solution (I wasn't aware of partition-by) Pete -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are mode

Learning clojure - comments on my function?

2011-09-29 Thread Peter Hull
Hi All, I am just learning clojure and I've written a function to split a list (see docstring for details). I was wondering if any of you experienced hands could take a look at it and comment. I've never used lisp or a functional language before so I was wondering if I was doing it right or if t