Re: Newbie Classpath issues on OSX

2020-10-10 Thread Jeremy Heiler
Can you share your project.clj and your project's directory structure? On Oct 3, 2020 at 6:17:36 PM, ok_computer wrote: > After reinstalling Leiningen via brew, I started getting classpath > errors. I uninstalled all my Clojure libs, deleted the ~/.lein folder and > started fresh with a new in

Newbie Classpath issues on OSX

2020-10-03 Thread ok_computer
After reinstalling Leiningen via brew, I started getting classpath errors. I uninstalled all my Clojure libs, deleted the ~/.lein folder and started fresh with a new install using 'brew install Leiningen' which gave me a new Clojure and Leiningen. It worked fine at first, until I tried creatin

Re: newbie trying to mod a clojure based game

2017-01-29 Thread James Reeves
If you have Leiningen installed, then run: lein cljsbuild once The compiled Javascript will be in target/app.js Admittedly this isn't very obvious to beginners unless you happen to guess what the cljsbuild plugin does. - James On 29 January 2017 at 23:45, James Thorne wrote: > I'm trying

newbie trying to mod a clojure based game

2017-01-29 Thread James Thorne
I'm trying to mod a game called epitaph from github https://github.com/mkremins/epitaph The cljs files inside the src are easy enough to understand and I foolishly thought modding those were all that was needed. I signed up to github, forked and modded, found out this task was not so simple, ab

Re: Newbie question

2016-09-05 Thread Andy Fingerhut
On Mon, Sep 5, 2016 at 9:25 AM, hiskennyness wrote: > > In other languages you might see: > > (defn himom [] ..) > (defn himom [x] ...) > (defn himom [x y z] ...) > > > Come to think of it, maybe Clojure does that, too, (nooby myself) but the > Clojure syntax for overloading I know puts each defi

Re: Newbie question

2016-09-05 Thread hiskennyness
On Sunday, September 4, 2016 at 4:58:34 PM UTC-4, Charlie wrote: > > I'm going through the Do Things: A Clojure Crash Course, and the following > example (in REPL) is presented: > > (defn recursive-printer > ([] > (recursive-printer 0)) > ([iteration] > (println iteration) > (

Re: Newbie question

2016-09-04 Thread Charlie
Thanx Colin & James - got it now - Charlie On Sunday, September 4, 2016 at 5:31:40 PM UTC-4, Colin Yates wrote: > > This form allows the fn to have multiple arities. So if I call > (recursive-printer) it will 'invoke' ([] (recursive-printer 0)). If I call > (recursive-printer 1) then it will 'in

Re: Newbie question

2016-09-04 Thread Colin Yates
This form allows the fn to have multiple arities. So if I call (recursive- printer) it will 'invoke' ([] (recursive-printer 0)). If I call (recursive- printer 1) then it will 'invoke' ([iteration] ...). HTH -- Colin Yates colin.ya...@gmail.com On Sun, 4 Sep 2016, at 09:54 PM, Charlie wrote

Re: Newbie question

2016-09-04 Thread James Reeves
Functions in Clojure can behave differently depending on the number of arguments they receive (their "arity"). A function can be written: (defn foo [x] (str "foo" x)) But you can also write: (defn foo ([] "empty foo") ([x] (str "foo" x)) This will do different things d

Newbie question

2016-09-04 Thread Charlie
I'm going through the Do Things: A Clojure Crash Course, and the following example (in REPL) is presented: (defn recursive-printer ([] (recursive-printer 0)) ([iteration] (println iteration) (if (> iteration 3) (println "Goodbye!") (recursive-printer (inc iteratio

Re: Clojure Newbie questions

2016-05-04 Thread Mark Engelberg
For the most part, you can program complex programs in Clojure without ever dropping down to Java. There are only a handful of Java libraries that are important to know well, primarily because Clojure chose not to implement certain functionality that is readily available on the host system. Examp

Re: Clojure Newbie questions

2016-05-04 Thread Leif
Hi, Bruce. I know almost no Java, and yet I have been a fairly productive professional Clojure programmer for several years. How is that possible? Here are my thoughts: 1. A lot of code is application logic. This will be 100% Clojure. 2. The next big chunk of code is talking to databases, we

Re: Clojure Newbie questions

2016-05-04 Thread Arnaud BOS
At last a question I can contribute to. There's certainly no need to be a Java "guru" to become "good" at Clojure, although it depends on what you definition of "being good at something" is. I'm far from being a Java guru, really, I've learned it only 8 years ago (at school) and only practiced for

Clojure Newbie questions

2016-05-04 Thread Bruce Whealton
Hello, There is much I like about Clojure - from it being a Lisp dialect to functional programming. I know it runs on the JVM. My question is this: If one is not a guru with Java will that be a problem becoming good at Clojure? The only thing that intimidates me about Java is the

Re: Newbie Question: Why is "reduced?" used in the reductions function?

2015-10-17 Thread Alex Eberts
Ah, that makes total sense. Thanks for the assistance! best, Alex On Saturday, October 17, 2015 at 7:35:00 AM UTC-4, Nicola Mometto wrote: > > > The `reduced?` check is there in case somebody returns a `reduced` as > acc value from the reducing function, as a way to terminate the > reduction ea

Re: Newbie Question: Why is "reduced?" used in the reductions function?

2015-10-17 Thread Nicola Mometto
The `reduced?` check is there in case somebody returns a `reduced` as acc value from the reducing function, as a way to terminate the reduction early: user=> (reductions (fn [_ x] (if (= 10 x) (reduced x) x)) (range)) (0 1 2 3 4 5 6 7 8 9 10) deref is the way to retrieve the value of a reduced o

Newbie Question: Why is "reduced?" used in the reductions function?

2015-10-17 Thread Alex Eberts
Hi All, Could someone please explain why reduced? is being used in the reductions function (below)? From what I understand reduced? checks if there has been a call to reduced and I don't see where that might be happening. Also, why is the deref macro being used with init? thanks, Alex (defn

Re: Newbie trying HTML parsing

2015-10-16 Thread edbond
Hello Mike, Take a look at hickory, it's more straightforward than enlive if you want to find something in html: https://github.com/davidsantiago/hickory (ns .. (:require [hickory.core :as h] [hickory.select :as hs] [cljs.core.async :as a])) let [html (:

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: Newbie trying HTML parsing

2015-10-15 Thread Mike
> > I've read the clojure.data.xml.zip docs carefully and looked at many > examples, but I don't understand this behavior: > (require '[clj-http.client :as client] '[clojure.zip :as z] '[clojure.data.zip :as dz] '[clojure.data.zip.xml :as dzx] '[crouton.html

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-14 Thread Mike
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 (:gen-class)) (require '[clj-http.client :as client] '[clojure.zip :as z] '[clojure.data.zip :as dz] '[clojure.data.zip.xml :as dzx]

Re: Newbie trying HTML parsing

2015-10-14 Thread Matching Socks
(Enlive wraps JSoup and TagSoup and causes them both to return a value in the same format as clojure.xml. Likewise, Enlive's transformation features will work with anything that looks like clojure.xml.) -- You received this message because you are subscribed to the Google Groups "Clojure" grou

Re: Newbie trying HTML parsing

2015-10-14 Thread James Reeves
I'm not that familiar with Enlive, so I can't comment on the ease of that approach. However, the way I'd personally do it is that I'd make use of Crouton and the zipper functions in clojure.zip and clojure.data.zip. A zipper is a functional way of navigating an immutable data structure. So first

Re: Newbie trying HTML parsing

2015-10-14 Thread Mike
Thanks James! You helped me get another step along the way, I got this working. Of course you mentioned Crouton; you should and I asked for advice on my approach. So please allow me to expand the problem statement and you may advise me further... Once I get this HTML parsed, I know that some

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

Newbie trying HTML parsing

2015-10-14 Thread Mike
Hello, For my first real Clojure project I am attempting to get an HTML page and locate a particular ** tag within the page. I have my program GETting the page, but I am having trouble parsing it. I am trying to use *clj-tagsoup* to parse the page, but I get an error message when I try to ;req

Re: newbie Q: how to tweak file-seq (original: how to selectively iterate through a tree of directories) ?

2015-10-05 Thread Andy-
Try to adapt my code: https://gist.github.com/rauhs/63054a06631c0be598d3 where you change your accept function to incorporate: http://stackoverflow.com/questions/813710/java-1-6-determine-symbolic-links HTH On Saturday, October 3, 2015 at 5:14:51 PM UTC-4, hpw...@gmail.com wrote: > > The direc

Re: newbie Q: where is isSymbolicLink function and how to access it ?

2015-10-05 Thread Ray Miller
You need Java interop for this: (import 'java.nio,file.Files) (Files/isSymbolicLink (.toPath (io/file "/some/path"))) See http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html for the other methods provided by this class. On 5 October 2015 at 16:47, wrote: > > In the clojure.java.

newbie Q: where is isSymbolicLink function and how to access it ?

2015-10-05 Thread hpwei01
In the clojure.java.io there are these two functions: isDirectory isFile But there is no isSymbolicLink (for unix, linux). (1) Could someone tell me where I can find such a function ? In another library not listed on clojure,org ?? (2) What do I need to do in order to use it ? Th

Re: newbie Q: how to tweak file-seq (original: how to selectively iterate through a tree of directories) ?

2015-10-03 Thread Gary Verhaegen
Sorry, I meant :when, not :where. Though it won't change the problem. Here's the rub: first file-seq produces its whole seq, then for comes along and filters out some of it. So (ignoring lazyness) file-seq ha already traversed symbolic links (at least for folders) by the time for sees it. I fear

Re: newbie Q: how to tweak file-seq (original: how to selectively iterate through a tree of directories) ?

2015-10-03 Thread hpwei01
The directory structure is /path/top/dir1 /path/top/dir1/f1 /path/top/dir1/f2 /path/top/dir2 -> /another/path/dir2 -- /another/path/dir2/g1 /another/path/dir2/g2 I tried this (following suggestion): (for [file (file-seq dir) :while (.isFile file)] (.getPath file))

Re: newbie question: how to selectively iterate through a tree of directories ?

2015-10-03 Thread Gary Verhaegen
I'm on Windows at the moment, so I can't test, but I think you can filter on isFile: (for [file (file-seq dir) :where (.isFile file)] (.getName file)) should work, I think. On 3 October 2015 at 07:36, wrote: > Under linux, I have a tree of directories like this: > > /path/top > > /path

newbie question: how to selectively iterate through a tree of directories ?

2015-10-03 Thread hpwei01
Under linux, I have a tree of directories like this: /path/top /path/top/dir1 (in here there are two files f1, f2) /path/top/dir2 -> /another-path/dir2 (a symbolic link) and under /another-path/dir2 there are two files g1, g2 If I use below code, I would get a list of file

Re: newbie question on agent/transaction

2015-07-15 Thread William la Forge
Or perhaps find a way to extend agents. hm? On Wednesday, July 15, 2015 at 9:45:29 AM UTC-4, William la Forge wrote: > > Thanks, Ragnar. > > My reason for asking is that I've implemented a robust form of actor in > Java https://github.com/laforge49/JActor2 and want to play with a > simplified ve

Re: newbie question on agent/transaction

2015-07-15 Thread William la Forge
Thanks, Ragnar. My reason for asking is that I've implemented a robust form of actor in Java https://github.com/laforge49/JActor2 and want to play with a simplified version in Clojure as a first project in the language. But I'm just hardly getting started. I've only been looking at Clojure for

Re: newbie question on agent/transaction

2015-07-15 Thread Ragnar Dahlén
You can check with `(clojure.lang.LockingTransaction/isRunning)` (the io! macro does this) but I'm not sure if it's considered a public API. https://github.com/clojure/clojure/blob/f6a90ff2931cec35cca0ca7cf7afe90ab99e3161/src/clj/clojure/core.clj#L2390 On Wednesday, 15 July 2015 13:53:11 UTC+1,

Re: newbie question on agent/transaction

2015-07-15 Thread Ragnar Dahlén
Hi Bill, You are correct in that this involves close integration with the STM. The agent implementation is aware of transactions and if a transaction is running when dispatching an action, it will be enqneued in a special agent action queue that STM implementation respects. AFAIK there is no p

newbie question on agent/transaction

2015-07-15 Thread William la Forge
On this page http://clojure.org/agents I read the following: "Agents are integrated with the STM - any dispatches made in a transaction are held until it commits, and are discarded if it is retried or aborted." So there must be a way to tell if a dispatch is made from within a transaction.

Re: Newbie

2015-05-01 Thread Brett Morgan
I second, http://www.braveclojure.com. It's a great tutorial. I've switch from using Emacs as IDE to Cursive, an Intellij plugin. https://cursiveclojure.com On Thursday, April 30, 2015 at 4:03:47 PM UTC-4, Jeff Heon wrote: > > I quite like these two resources for total beginners. > > (Starts

Re: Newbie

2015-04-30 Thread Jeff Heon
I quite like these two resources for total beginners. (Starts up assuming you know nothing about Lisp.) aphyr.com/tags/Clojure-from-the-ground-up (Quite humorous) http://www.braveclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post t

Re: Newbie

2015-04-30 Thread Gary Schiltz
he presentation that describing about Clojure for > newbie developer to make more easy to understand? > > Thanks, > Pitou > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegro

Newbie

2015-04-30 Thread Pitou Khmer
Dear all experts here, Could you share me the presentation that describing about Clojure for newbie developer to make more easy to understand? Thanks, Pitou -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, sen

Re: Newbie question about filtrering defrecord

2015-04-04 Thread Paul L. Snyder
On Sun, 05 Apr 2015, Michael Blume wrote: > your list doesn't contain the records, your list contains the symbols 'a1 > and 'a2. You can't make a list the way you're trying to. To be specific, you're quoting the list in your def, so the a1 and a2 symbols are not evaluated. user=> (defrecord A

Re: Newbie question about filtrering defrecord

2015-04-04 Thread Michael Blume
your list doesn't contain the records, your list contains the symbols 'a1 and 'a2. You can't make a list the way you're trying to. On Sat, Apr 4, 2015 at 5:14 PM Luc Préfontaine wrote: > You mean the a1 record no ? > > > > Hi! > > > > I'm new to clojure, and have problem understanding how to fil

Re: Newbie question about filtrering defrecord

2015-04-04 Thread Luc Préfontaine
You mean the a1 record no ? > Hi! > > I'm new to clojure, and have problem understanding how to filter a list of > defrecords. > I have tried different variations on the following: > > (defrecord Ape [fname lname]) > (def a1 (->Ape "test1" "test2")) > (def a2 (->Ape "test3" "test4")) > (def a

Newbie question about filtrering defrecord

2015-04-04 Thread Magnus Javerberg
Hi! I'm new to clojure, and have problem understanding how to filter a list of defrecords. I have tried different variations on the following: (defrecord Ape [fname lname]) (def a1 (->Ape "test1" "test2")) (def a2 (->Ape "test3" "test4")) (def alist '(a1 a2)) (filter #(= "test1" (:fname %)) al

Re: Newbie re-implement 'interleave' found type conversion error

2015-04-02 Thread Stephen Wakely
Instead of : (if (s1) You just want : (if s1 s1 is a Long, not a function. On Thu, Apr 2, 2015 at 8:56 AM michael zhuang wrote: > : i'm new to clojure, when I try to implementation 'interleave', get error > from type convertion "java.lang。Long cannot be cast to clojure.lang.IFN". > ; Now

Newbie re-implement 'interleave' found type conversion error

2015-04-02 Thread michael zhuang
: i'm new to clojure, when I try to implementation 'interleave', get error from type convertion "java.lang。Long cannot be cast to clojure.lang.IFN". ; Now im reading stack trace, try to figure out what's going on.. (defn myIL [col1 col2] (loop [m [] s1 (first col1) s2 (fi

Re: A newbie question with using parkour

2015-02-22 Thread Sunil S Nandihalli
Thanks Jeremy for the response. I was using clojure-1.7.0-alpha5 , parkour 6.2that looked was the original problem. After I changed the version to clojure-1.6.0 I got past that problem and hit a new set of problems. Marshall suggested that the issue could be because of mismatched hadoop-versions. I

Re: A newbie question with using parkour

2015-02-22 Thread Jeremy Heiler
What version of parkour are you using? That will help us match line numbers in the stracktrace with the code. -- 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 membe

A newbie question with using parkour

2015-02-22 Thread Sunil S Nandihalli
Hi Everybody, I am complete newbie to using parkour. I am having trouble just reading in data. Can somebody help me figure out the problem. The code I am using is here.. https://gist.github.com/52f4298e5b6ca6a46699 I agree that there is no other stage apart from the input. I had all other

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

2015-02-13 Thread Fluid Dynamics
Then all of them must be schizophrenic: forcing delay X while forcing delay X gives a stack overflow except if the delay happens to be the rest-part of a lazy seq, and then gives nil instead making the sequence seem to terminate early. That's very odd. How does it "know" whether the delay it's

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

2015-02-13 Thread Nicola Mometto
Clojure 1.6.0 user=> (def foo (delay (str @foo))) #'user/foo user=> @foo StackOverflowError clojure.lang.Delay.deref (Delay.java:37) user=> same with Clojure 1.7.0-master-SNAPSHOT, I don't see it returning nil as you said. On Fri, Feb 13, 2015 at 7:53 AM, Fluid Dynamics wrote: > On Friday, Feb

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

2015-02-13 Thread Nicola Mometto
Clojure 1.5.1 user=> (def bar (cons 1 (map #(do (println %) (+ (nth bar %) %)) (range #'user/bar user=> (take 10 bar) (0 1 IndexOutOfBoundsException clojure.lang.RT.nthFrom (RT.java:795) It is possible that it is lein/REPLy that's causing the output not to be print, I've seen it done a num

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

2015-02-12 Thread Fluid Dynamics
And here's some really crazy behavior from 1.5.1! => (def bar (cons 1 (map #(do (println %) (+ #_(nth bar %) %)) (range #'user/bar => (take 10 bar) (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 0 1 2 3 4 5 6 7 8) => (def bar (cons 1 (map #(do (println

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

2015-02-12 Thread Fluid Dynamics
On Friday, February 13, 2015 at 12:47:17 AM UTC-5, Justin Smith wrote: > > I don't want to sound too brusque in my defense of Clojure. I'm a huge > fan, so criticism of the language does get me a bit defensive. > I am a fan as well. Constructive criticism is useful as it can lead to improvements

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

2015-02-12 Thread Justin Smith
To go into a bit more detail about what this code does: Here's the code formatted idiomatically - (defn divides? [x y] (zero? (mod x y))) (defn prime-ub [x] (/ x (if (even? x) 2 3))) (defn lower-primes [primes x] (let [ub (prime-ub x)] (take-while #(<= % ub) primes))) (defn prime? [prime

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

2015-02-12 Thread Fluid Dynamics
On Friday, February 13, 2015 at 12:05:24 AM UTC-5, 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 error. Nope. Every component of the sequence should

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

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

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

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

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

2015-02-12 Thread Fluid Dynamics
On Thursday, February 12, 2015 at 11:24:03 PM UTC-5, Justin Smith wrote: > > 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.

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

2015-02-12 Thread Timothy Baldridge
Oh, it's much worse than anyone has mentioned yet. The whole (def primes ...) bit is also a problem. What you are saying to the compiler is "create a var named primes and assign it this lazy-seq...", and then while defining that lazy seq you are creating closures that use "primes". That sort of cir

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

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

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

2015-02-12 Thread Jorge Marques Pelizzoni
I really fail to see how this can be related to chunking. So in: (def primes (cons 2 (lazy-seq (filter #(prime? primes %) (drop 3 (range)) *prime?* would be being called with unbound *primes*? And no exception would be raised and again no 4 or even numbers left to testify? Em sexta-feira,

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

2015-02-12 Thread Justin Smith
Clojure is quite elegant, but it's not always unsurprising. Even if one surprising behavior around lazy-seq realization is changed, others are likely to continue to occur. The solution to this is to not write code that implicitly relies on a specific timing of lazy realization. If you need resu

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

2015-02-12 Thread Jorge Marques Pelizzoni
Even THIS works now: (defn primes [] (let [primes' (atom nil)] (reset! primes' (cons 2 (filter #(prime? @primes' %) (iterate inc 3)) Em sexta-feira, 13 de fevereiro de 2015 01:28:13 UTC-2, Jorge Marques Pelizzoni escreveu: > > Anyway, I would be in awe that being Closure

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

2015-02-12 Thread Jorge Marques Pelizzoni
Anyway, I would be in awe that being Closure such an expressive and elegant language its user base is really ok with an state of affairs in which: (def primes (cons 2 (lazy-seq (filter #(prime? primes %) (drop 3 (range)) does not mean what it obviously should and above all means something

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

2015-02-12 Thread Justin Smith
no, we have not moved past this, and the error is absolutely because you take too much for granted about lazy behavior (defn divides? [x y] (zero? (mod x y))) (defn prime-ub [x] (/ x (if (even? x) 2 3))) (defn lower-primes [primes x] (let [ub (prime-ub x)] (println "primes" primes "x" x) (tak

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

2015-02-12 Thread Jorge Marques Pelizzoni
So why isn't 4 and any even numbers in the result list? Empty primes' allows everything to pass. We are already beyond this. I've already posted that even this does not work: (def primes (cons 2 (lazy-seq (filter #(prime? primes %) (drop 3 (range)) Em sexta-feira, 13 de fevereiro de 2015

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

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

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

2015-02-12 Thread Jorge Marques Pelizzoni
Not even this works (in which I try to avoid state mutation): (def primes (cons 2 (lazy-seq (filter #(prime? primes %) (drop 3 (range)) Em quinta-feira, 12 de fevereiro de 2015 23:26:03 UTC-2, Fluid Dynamics escreveu: > > AFAICT the issue here is combining lazy evaluation with state mutat

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

2015-02-12 Thread Fluid Dynamics
AFAICT the issue here is combining lazy evaluation with state mutation. Don't do that. :) -- 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 - p

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

2015-02-12 Thread Jorge Marques Pelizzoni
Beautiful, Armando! Thanks for your the insight. Anyway, I really don't buy the "that's the way it is" argument. Totally looks like a bug and I don't find it a coincidence it is working differently in the development branch. Thank you all for your time :) Em quinta-feira, 12 de fevereiro de 20

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

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

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

2015-02-12 Thread Armando Blancas
Jorge, I tried this on 1.6 and seemed to work: (def primes (cons 2 (for [n (iterate inc 3) :when (prime? primes n)] n))) On Thursday, February 12, 2015 at 4:21:45 PM UTC-8, Jorge Marques Pelizzoni wrote: > > Neither did delay help: > > (defn primes [] (let [primes' (atom nil)] >

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

2015-02-12 Thread Andy Fingerhut
Laziness is pervasive in Haskell, for all computation (unless you force it off with special constructs). Laziness in Clojure is as pervasive as sequences, but it is not for all computation like in Haskell, and sequences have the previously-mentioned features of sometimes-more-eager-than-the-minimu

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

2015-02-12 Thread Jorge Marques Pelizzoni
Neither did delay help: (defn primes [] (let [primes' (atom nil)] (reset! primes' (delay (cons 2 (filter #(prime? (force (deref primes')) %) (drop 3 (range Serious this is not a bug? Em quinta-feira, 12 de fevereiro de 2015 22:14:46 UTC-2, Jorge Marques Pelizzoni esc

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

2015-02-12 Thread Jorge Marques Pelizzoni
Thanks, Michael, for your analysis and explanation. However not even this worked: (defn primes [] (let [primes' (atom nil)] (lazy-seq (reset! primes' (lazy-seq (cons 2 (lazy-seq (filter #(prime? (deref primes') %) (drop 3 (range)) And one thing we klnow for sure is th

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

2015-02-12 Thread Michael Blume
Hmm, upon further investigation I think I would not call this a bug in Clojure that got fixed, I think I'd call this an unspecified behavior in Clojure that happened to break your function and now happens to allow it to work. Your function depends heavily on Clojure's laziness, and laziness is an

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

2015-02-12 Thread Andy Fingerhut
Or perhaps 1.7.0-alpha5 has a change vs. 1.6.0 that makes this code work by accident. Using lazy sequences to define later elements in terms of the prefix of the sequence up to that point has come up multiple times, usually with the example of generating primes (but different code each time). I d

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

2015-02-12 Thread Jorge Marques Pelizzoni
Well, that's a bug then :) And seems to have been fixed. Thanks! Em quinta-feira, 12 de fevereiro de 2015 17:51:13 UTC-2, Michael Blume escreveu: > > Oh, well this is fun -- with bleeding edge clojure I get the right answer, > but with 1.6.0 I see the same results you did. > > > -- You receive

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

2015-02-12 Thread Michael Blume
Oh, well this is fun -- with bleeding edge clojure I get the right answer, but with 1.6.0 I see the same results you did. On Thu Feb 12 2015 at 11:47:54 AM Michael Blume wrote: > Strange, when I run your code I don't get 9 or 15 > > On Thu Feb 12 2015 at 11:02:00 AM Jorge Marques Pelizzoni < > j

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

2015-02-12 Thread Michael Blume
Strange, when I run your code I don't get 9 or 15 On Thu Feb 12 2015 at 11:02:00 AM Jorge Marques Pelizzoni < jorge.pelizz...@gmail.com> wrote: > Hi, there! Please bear with me as I am very new to Closure (this is my > second program ever) but have a kind of solid Haskell background. > > I was tr

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

2015-02-12 Thread Jorge Marques Pelizzoni
Hi, there! Please bear with me as I am very new to Closure (this is my second program ever) but have a kind of solid Haskell background. I was trying to get a version of this Haskell code: divides x y = mod x y == 0 primeub x = div x (if even x then 2 else 3) isprime primes x = all (not . divide

Re: Newbie Gloss questions - dynamic buffer structure

2015-01-12 Thread Zach Tellman
I'm sorry, that should have been :ubyte. Being able to insert arbitrary data into a codec is a feature, though. On Mon, Jan 12, 2015 at 6:27 AM, Tzach wrote: > Hi Zach > Thanks for the detailed response > > On Wednesday, January 7, 2015 at 7:28:06 AM UTC+2, Zach Tellman wrote: >> >> Hey Tzach, >

Re: Newbie Gloss questions - dynamic buffer structure

2015-01-12 Thread Tzach
Hi Zach Thanks for the detailed response On Wednesday, January 7, 2015 at 7:28:06 AM UTC+2, Zach Tellman wrote: > > Hey Tzach, > > If I understand what you're trying to do, you want something like this: > > [ :uint32 > :ubyte ;; or bit-seq, depending > (delimited-block (prefix uint24 #(- % 5)

Re: Newbie Gloss questions - dynamic buffer structure

2015-01-06 Thread Zach Tellman
Hey Tzach, If I understand what you're trying to do, you want something like this: [ :uint32 :ubyte ;; or bit-seq, depending (delimited-block (prefix uint24 #(- % 5) #(+ % 5))) ] And then you'll need to parse the final block separately. I've left defining the uint24 as an exercise for the

Newbie Gloss questions - dynamic buffer structure

2015-01-03 Thread Tzach
I'm trying to work with Gloss binary encoder/decoder, and need some help to kick start. My first task is simple(not for me ;) I have the following binary buffer to read/write: - 4 byte (32 bit) - code (uint) - 8 bit - misc flags - 3 byte (24 bit) - the entire buffer length - 4 byte (

Re: [Very newbie] invocation of java code.

2014-10-01 Thread Tobias Kortkamp
java.util.TimerTask is an abstract class, which you cannot instantiate directly. You can use proxy to create a subclass: (proxy [java.util.TimerTask] [] (run [] ...)) Instead of (new java.lang.Boolean ...) use true or false directly. There is syntactic sugar for new, just append a dot to the

[Very newbie] invocation of java code.

2014-10-01 Thread paracomunicacionesinformales
hi I'm running clojure REPL ( I think ), in its lein-less version ( no lein at all, raw clojure.jar): java -cp clojure-1.6.0.jar clojure.main Then I try to create an object of class java.util.TimerTask by: user=> (new java.util.TimerTask (new java.lang.Boolean 1)) CompilerException java.lang

Re: pigpen newbie question

2014-09-15 Thread Sunil S Nandihalli
Thanks Matt for the response. Like you said, I don't really need to be using 1.7.0 I am doing quiet ok with 1.6.0 Thanks, Sunil. On Tue, Sep 16, 2014 at 9:28 AM, 'Matt Bossenbroek' via Clojure < clojure@googlegroups.com> wrote: > Sunil, > > I tried upgrading PigPen to Instaparse 1.3.4, but that p

Re: pigpen newbie question

2014-09-15 Thread 'Matt Bossenbroek' via Clojure
Sunil, I tried upgrading PigPen to Instaparse 1.3.4, but that pulled in Clojure 1.6.0 & now I'm running into some build/jar/versioning issues. I don't think I'll be able to get the update out as soon as promised, but it sounds like not using 1.7.0 will work for you in the meantime. -Matt On

Re: pigpen newbie question

2014-09-11 Thread Sunil S Nandihalli
Thanks Mark and Matt, changing the version back to clojure version 1.6.0 fixed it. Sunil On Fri, Sep 12, 2014 at 7:05 AM, 'Matt Bossenbroek' via Clojure < clojure@googlegroups.com> wrote: > Just saw this response - disregard the questions I asked you on the > pigpen support DL. > > I'll pull in

Re: pigpen newbie question

2014-09-11 Thread Sunil S Nandihalli
Thanks Mark for the response. That was very quick. Let me see if moving to clojure 1.6.0 fixes the issues. Sunil. On Fri, Sep 12, 2014 at 6:58 AM, Mark Engelberg wrote: > You're probably using Clojure 1.7.0 alpha 2, which introduced a new > function called "cat" into the core namespace, which ov

Re: pigpen newbie question

2014-09-11 Thread 'Matt Bossenbroek' via Clojure
Just saw this response - disregard the questions I asked you on the pigpen support DL. I'll pull in the new instaparse & get a new PigPen build out soonish (within a day or two). -Matt On Thursday, September 11, 2014 at 6:28 PM, Mark Engelberg wrote: > You're probably using Clojure 1.7.0 a

Re: pigpen newbie question

2014-09-11 Thread mbossenbroek via Clojure
That's a weird one :) Couple of questions... What version of pigpen are you using? What are you using to compile & produce that output? It doesn't look like lein or gradle output. What OS are you using? Do you have a full sample project to repro? Does your project have any other references? Some

Re: pigpen newbie question

2014-09-11 Thread Mark Engelberg
You're probably using Clojure 1.7.0 alpha 2, which introduced a new function called "cat" into the core namespace, which overlaps with a function in instaparse. A couple nights ago, I updated instaparse to version 1.3.4, with an update to deal with this change in alpha 2, but pigpen has not yet be

pigpen newbie question

2014-09-11 Thread Sunil S Nandihalli
Hi , I am trying to compile a simple clj file which does nothing apart from requiring the pigpen name-space and it fails to compile with the following error. Can anybody help? Attempting to call unbound fn: #'instaparse.combinators-source/cat the full stack trace is here. https://gist.github.com

Re: Newbie: adding items to a global vector in doseq

2014-08-14 Thread Tassilo Horn
phi...@free.fr writes: > I have read up on atoms and used swap! to set the urls2 vector atom in > my code. Thanks. > > One problem remains though: I can't retrieve the atom vector's items > > *(nth urls 10)* > > throws the following exception > > java.lang.UnsupportedOperationException: nth not su

  1   2   3   4   5   6   7   8   9   10   >