Re: common ways to run regex against either Hickory HTML or zippers?

2022-02-02 Thread Mark Nutter
I don't know how common it is, but have you looked at the `tree-seq`
function in Clojure? This seems like a good use case for it.

Mark

On Wed, Feb 2, 2022 at 3:22 PM lawrence...@gmail.com <
lawrence.krub...@gmail.com> wrote:

> Assume I've been cursed to scrape HTML. If I convert the pages to Hickory
> I end up with a big mass of data which, sadly, lacks many "class" or "id"s
> that would let me easily pick out the data I need. However, for the most
> part, the only thing I really need off this page is the CVEs, which look
> like this:
>
> CVE-2021-40539
>
> I'm thinking I might write regex against the plain text of the page, but
> I'm also curious, is it common to take something like Hiccup or Hickory or
> a zipper and run regex through it? If yes, how is that done?
>
> A small part of the data looks like this:
>
> :content
> [{:type :element,
>   :attrs
>   {:class "tip-intro", :style "font-size: 15px;"},
>   :tag :p,
>   :content
>   [{:type :element,
> :attrs nil,
> :tag :em,
> :content
> ["This Joint Cybersecurity Advisory uses the MITRE
> Adversarial Tactics, Techniques, and Common Knowledge (ATT®) framework,
> Version 8. See the "
>  {:type :element,
>   :attrs
>   {:href
>"
> https://attack.mitre.org/versions/v9/techniques/enterprise/"},
>   :tag :a,
>   :content ["ATT for Enterprise"]}
>  " for  referenced threat actor tactics and for
> techniques."]}]}
>  "\n\n"
>  {:type :element,
>   :attrs nil,
>   :tag :p,
>   :content
>   ["This joint advisory is the result of analytic efforts
> between the Federal Bureau of Investigation (FBI), United States Coast
> Guard Cyber Command (CGCYBER), and the Cybersecurity and Infrastructure
> Security Agency (CISA) to highlight the cyber threat associated with active
> exploitation of a newly identified vulnerability (CVE-2021-40539) in
> ManageEngine ADSelfService Plus—a self-service password management and
> single sign-on solution."]}
>  "\n\n"
>  {:type :element,
>   :attrs nil,
>   :tag :p,
>   :content
>   ["CVE-2021-40539, rated critical by the Common
> Vulnerability Scoring System (CVSS), is an authentication bypass
> vulnerability affecting representational state transfer (REST) application
> programming interface (API) URLs that could enable remote code execution.
> The FBI, CISA, and CGCYBER assess that advanced persistent threat (APT)
> cyber actors are likely among those exploiting the vulnerability. The
> exploitation of ManageEngine ADSelfService Plus poses a serious risk to
> critical infrastructure companies, U.S.-cleared defense contractors,
> academic institutions, and other entities that use the software. Successful
> exploitation of the vulnerability allows an attacker to place webshells,
> which enable the adversary to conduct post-exploitation activities, such as
> compromising administrator credentials, conducting lateral movement, and
> exfiltrating registry hives and Active Directory files."]}
>  "\n\n"
>
> --
> 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.
> 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 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/clojure/5f2bd2a4-5c35-463b-9cb4-eecb9148fc89n%40googlegroups.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 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/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 

Re: Pesky java interop bug with 0xFFFFFFF error in BuferredReader

2021-12-25 Thread Mark Nutter
I think at least part of the problem is your use of val in the let
statement. Inside the loop, you're testing (not (= val -1)),  but val is an
immutable value defined above the loop as being the first character read
from the buffer, so it will always loop until it reads in the 0xFFF
that makes it crash. You probably want to modify your loop like this:

(loop [val (.read bfr)]
  (when (not (= val -1))
(.append ct (Character/toChars val)))
(recur (.read bfr))

Now this re-assigns the next character from the buffer to val each time you
go through the loop.

I'm not a guru when it comes to Java interop, but I think the above is the
main problem you're having right now, so hopefully that will get you back
on track.


On Sat, Dec 25, 2021 at 2:23 PM Hank Lenzi  wrote:

>
> Hello --
>
> I'm learning Clojure and its Java interop stuff. I am trying to emulate
> this function:
>
>  public String readAllCharsOneByOne(BufferedReader bufferedReader) throws
> IOException {
> StringBuilder content = new StringBuilder();
>
> int value;
> while ((value = bufferedReader.read()) != -1) {
> content.append((char) value);
> }
>
> return content.toString();
> }
>
>
> So far, I've been able to reason that the parts I need are:
>
>
> (def myfile "/path/to/svenska_sample.txt")
> (import java.io.BufferedReader)
> (import java.io.FileReader)
> (import java.lang.StringBuilder)
> (import java.lang.Character)
>
> (def a-FileReader (FileReader. myfile))
> (def bufferedReader (BufferedReader. a-FileReader))
> (def content (StringBuilder.))
>
> which works
>
> user> (.append content (Character/toChars (.read bufferedReader)))
> #object[java.lang.StringBuilder 0x490447d0 "\nDe"]
> user> (.append content (Character/toChars (.read bufferedReader)))
> #object[java.lang.StringBuilder 0x490447d0 "\nDen"]
> user> (.append content (Character/toChars (.read bufferedReader)))
> #object[java.lang.StringBuilder 0x490447d0 "\nDen "]
> user> (.append content (Character/toChars (.read bufferedReader)))
> #object[java.lang.StringBuilder 0x490447d0 "\nDen t"]
> user> (.append content (Character/toChars (.read bufferedReader)))
> #object[java.lang.StringBuilder 0x490447d0 "\nDen ty"]
> user> (.append content (Character/toChars (.read bufferedReader)))
> #object[java.lang.StringBuilder 0x490447d0 "\nDen typ"]
> user> (.append content (Character/toChars (.read bufferedReader)))
> #object[java.lang.StringBuilder 0x490447d0 "\nDen typi"]
>
> The file is a small text file UTF-8 encoded in Linux with the following
> content:
>
> ❯ cat svenska_sample.txt
>
> Den typiska impulsiva olycksfågeln är en ung man som kraschar flera bilar,
> och ofta skryter lite med det, i varje fall när han är tillsammans med sina
> vänner._. För dem har otur i det närmaste blivit en livsstil, och de råkar
> konstant ut för olyckor, stora som små. Olycksfåglar kallar vi dem. Hur
> många det finns kan ingen med säkerhet säga, för det finns inga konkreta
> definitioner på denna grupp, och heller ingen given avgränsning av den. Att
> de finns, råder det emellertid ingen tvekan om, varken på sjukhusens
> akutmottagningar eller i försäkringsbranschen
>
> I wrote a function, with my brand new Clojure Java interop chops, that
> looks like this:
>
> ;; COMPILES  - BUT CAN'T GET AROUND THE 0XFFF BUG
> (defn pt%% [file]
>(let [afr (FileReader. file); instances of FileReader, BufferedReader,
> StringBuffer
>  bfr (BufferedReader. afr)
>  ct (StringBuilder.)
>  val (.read bfr)
>  this-list (list afr bfr ct)]
>  ; (apply println this-list)
>  (loop []
>(when (not (= val -1))
>  (.append ct (Character/toChars (.read bfr
>(recur))
> ; when finished...
>  (.toString ct)))
>
> but it borks with the following error:
>
> user> (pt%% myfile)
> Execution error (IllegalArgumentException) at java.lang.Character/toChars
> (Character.java:8572).
> Not a valid Unicode code point: 0x
>
> What in the world could be causing this (NOTE: I am not a Java
> programmer)?
> Here is the hex dump of the file text file:
>
> ❯ cat svenska_sample.hexdump
> : 0a44 656e 2074 7970 6973 6b61 2069 6d70  .Den typiska imp
> 0010: 756c 7369 7661 206f 6c79 636b 7366 c3a5  ulsiva olycksf..
> 0020: 6765 6c6e 20c3 a472 2065 6e20 756e 6720  geln ..r en ung
> 0030: 6d61 6e20 736f 6d20 6b72 6173 6368 6172  man som kraschar
> 0040: 2066 6c65 7261 2062 696c 6172 2c20 6f63   flera bilar, oc
> 0050: 6820 6f66 7461 2073 6b72 7974 6572 206c  h ofta skryter l
> 0060: 6974 6520 6d65 6420 6465 742c 2069 2076  ite med det, i v
> 0070: 6172 6a65 2066 616c 6c20 6ec3 a472 2068  arje fall n..r h
> 0080: 616e 20c3 a472 2074 696c 6c73 616d 6d61  an ..r tillsamma
> 0090: 6e73 206d 6564 2073 696e 6120 76c3 a46e  ns med sina v..n
> 00a0: 6e65 722e 5f2e 2046 c3b6 7220 6465 6d20  ner._. F..r dem
> 00b0: 6861 7220 6f74 7572 2069 2064 

Re: Why did this compile? It's an obvious syntax mistake

2018-12-26 Thread Mark Nutter
My guess would be that it failed to compile, and the weird behavior is that
it swallowed the "Failed" message somehow. That would be consistent with
the behavior you saw (couldn't call your start fn).

On Wed, Dec 26, 2018 at 11:59 AM  wrote:

> I'm wondering why this compiled?
>
> I was supposed to add this to my requirements:
>
> [environ.core :refer [env]]
>
> Instead I added this:
>
> [environ.core :refer [env]
>
> I rebuilt this, and it compiled. Then, in the cider REPL, I tried to call
> my "start" function. I was told it didn't exist, which was a big surprise,
> since I was looking right at it.
>
> It took me a few minutes to track down the problem. The problem was the
> missing "]". Okay, easy to fix, but why did it compile?
>
>
>
> --
> 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.
> 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 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.
>

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


Re: Doc strings for complex cases?

2017-11-05 Thread Mark Nutter
That actually sounds like a kind of code smell to me. If your different
arities/defmethods are doing such disparate things that you can't easily
describe them in a single docstring, it's worth asking whether they need to
be separate functions.

On Sun, Nov 5, 2017 at 7:59 AM, Tim  wrote:

> I'm seeing a need to assign a doc string per arity case for defn and also
> for each defmethod as opposed to storing it all in defmulti. Any solutions
> or plans for this?
> Tim
>
> --
> 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.
> 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 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.
>

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


Re: Is the Learning Guide in Order?

2017-10-11 Thread Mark Nutter
See also https://www.braveclojure.com/.

On Tue, Oct 10, 2017 at 9:11 PM, Tomiwa Ademidun 
wrote:

> Hey guys,
>
> I Finally started learning Lisp/Clojure thanks to inspiration from the
> great Paul Graham's essays . First, I
> wanted to say I appreciate your work in putting together the tutorial and
> clojure-docs website, its very helpful and I really appreciate all your
> efforts.
>
> After working through the introduction
> , I'm about
> to start the language guide
> . I was
> just wondering if there is a recommended order in which to work through the
> guide (or should I do a tutorial and then use the guide as a reference?).
> I'm assuming I should start with functions, if so, what comes after that as
> I am a bit overwhelmed by all the things I don't know :)
>
>
> Thanks,
> Tomiwa
>
> --
> 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.
> 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 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.
>

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


Re: Application silently shuts down by itself after running for some hours

2017-03-07 Thread Mark Nutter
I see this thread is going on for a while, and I'll say up front that I
don't have any helpful insights. I did see an interesting talk at
Abstractions, though, about how to use dtrace to get to the bottom of weird
problems like this. The video for that event doesn't seem to be online
anywhere, but the speaker gave a similar talk at !!Con, and that one is
online. If you're still having issues you might want to check this out, in
case it gives you an extra tool to use for tracking this down.

https://www.youtube.com/watch?v=1OMX69KOhGg

Good luck.


On Fri, Mar 3, 2017 at 10:57 AM, JokkeB  wrote:

> I have an application which I run with "lein run". The main looks
> something like this
>
> (defn -main []
>  (log/info "start")
>  (log/info "channel returned" (async/ ) (websocket-server 9122
>  (log/info "quit"))
>
> start-server returns a channel created with async/reduce which shouldn't
> ever produce a value. I see the "start" logged, the application runs for a
> day or two (not sure if the time is always the same) and then it closes
> without any errors or without logging "channel returned" or "quit".
>
> If there is an error in my code and the program quits I should see the
> "quit" message. If there is a memory leak or something I would assume I'd
> get an error message. Has anyone experienced anything similar?
>
> Could the reason be running it with lein (I haven't tried a jar)? If so,
> why?
>
> --
> 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.
> 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 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.
>

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


Re: What does "Map literal must contain an even number of forms" mean?

2016-12-04 Thread Mark Nutter
​In other languages, curly braces are used to enclose executable
statements, so something like { println("Hello world\n"); }​ makes sense.
In Clojure, however, curly braces are used to enclose a list of key/value
pairs, aka a map. So when  you say

{hash-map :c "Turd" :d "More Turd"}

you are creating a data structure with 2 and a half pairs. The first pair
uses the function hash-map as the key, and :c as the value; then "Turd" as
the next key and :d as the value; then "More Turd" as the last key, and no
value, causing the error.

On Sun, Dec 4, 2016 at 3:18 PM, bill nom nom 
wrote:

> ;; This works,
> (hash-map :a 1 :b 2 )
>
>
> ;; Here's another way to create a hash map, this won't work because map
> ;; literal must contain even number of forms
>  {hash-map :c "Turd" :d "More Turd"}
>
> What does "Map literal must contain an even number of forms" mean?
>
> --
> 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.
> 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 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.
>

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


Re: How to do functional programming

2015-10-09 Thread Mark Nutter
Neal Ford has a good talk on "Functional Thinking"
https://www.youtube.com/watch?v=7aYS9PcAITQ

On Fri, Oct 9, 2015 at 5:13 AM, Colin Yates  wrote:

> he he.
>
> Coming from many years of ‘Java Enterprise Applications’ (e.g. Spring,
> Hibernate and if you were feeling adventurous maybe free marker instead of
> JSP - h.) this was a wonderful breath of fresh air for me.
> https://www.coursera.org/course/proglang looks great as well.
>
> > On 9 Oct 2015, at 01:19, Sean Corfield  wrote:
> >
> > On 10/8/15, 1:32 PM, "Colin Yates"  of colin.ya...@gmail.com> wrote:
> >
> >
> >> This is a great course. I still get a bit green with envy when I recall
> the workbook capabilities in Eclipse. Another recommendation for Brian
> Marick’s OO to FP book.
> >
> > Ah, just realized this is Odersky’s course which is not what I was
> thinking of! I really did NOT enjoy the progfun course. I found the
> exercises boring and I found Scala itself fussy and annoying (and I _hate_
> Eclipse!). And this is from someone who did Scala in production for about
> 18 months before switching to Clojure in 2011!
> >
> > The course I was thinking of, which I praised so highly was actually
> this one:
> >
> > https://www.coursera.org/course/proglang
> >
> > Programming Languages, University of Washington, Professor Dan Grossman.
> >
> > That’s the one I enjoyed so much I took it three times!
> >
> > It starts out with Standard ML to teach you about statically typed FP,
> then it moves on to Racket to teach you about dynamically typed FP, then it
> wraps up with Ruby to look at how dynamically typed OOP contrasts with the
> two FP approaches.
> >
> > Sean
> >
> >>
> >>> On 8 Oct 2015, at 21:00, Sean Corfield  wrote:
> >>>
> >>> On 10/8/15, 12:45 PM, "Raoul Duke"  behalf of rao...@gmail.com> wrote:
> >>>
> >>>
>  i did this one a while back as a refresher on my university stuff :-)
>  https://www.coursera.org/course/progfun
> >>>
> >>> I’ll second this as a great recommendation. I first took the course
> several years ago and I’ve taken it twice since as a Community TA — that’s
> how much I like that course! :)
> >>>
> >>> It is switching from scheduled to on-demand so it won’t be available
> for a while yet, but then folks will be able to take it whenever they want,
> at their own speed.
> >>>
> >>> Sean
> >
> >
> > --
> > 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.
> > 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 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.
>
> --
> 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.
> 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 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.
>

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


Re: Clojure in Action, Second Edition

2015-10-09 Thread Mark Nutter
The first edition was a tremendous help when I was first learning Clojure.
Glad to see there's an update.

On Wed, Oct 7, 2015 at 5:16 PM, BarreisR  wrote:

> New and very useful book by author Amit Rathore.
> https://www.manning.com/books/clojure-in-action-second-edition
>
> --
> 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.
> 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 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.
>

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


Re: Neighbors function from The Joy of Clojure

2014-11-05 Thread Mark Nutter
A bit off the original topic, but this seemed like a good place to give a
shout out to my favorite intro book: Clojure In Action (
http://www.manning.com/rathore/). There are a lot of really excellent intro
books out there, and I don't want to disparage any of them, but I found
this one very readable. I think there's a 2nd edition in the works to bring
it up to date too.

On Tue, Nov 4, 2014 at 8:57 PM, Pierre Thibault pierre.thibau...@gmail.com
wrote:

 Ouch! I found this code hard to understand. I read to previous part of the
 book. I guess it is normal when you are new to Clojure?

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


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


Re: Neighbors function from The Joy of Clojure

2014-11-05 Thread Mark Nutter
​Forgot to add that my usual recommendation is Clojure in Action followed
by The Joy of Clojure. Killer combo.​

On Wed, Nov 5, 2014 at 7:34 AM, Mark Nutter manutte...@gmail.com wrote:

 A bit off the original topic, but this seemed like a good place to give a
 shout out to my favorite intro book: Clojure In Action (
 http://www.manning.com/rathore/). There are a lot of really excellent
 intro books out there, and I don't want to disparage any of them, but I
 found this one very readable. I think there's a 2nd edition in the works to
 bring it up to date too.

 On Tue, Nov 4, 2014 at 8:57 PM, Pierre Thibault 
 pierre.thibau...@gmail.com wrote:

 Ouch! I found this code hard to understand. I read to previous part of
 the book. I guess it is normal when you are new to Clojure?

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




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


Re: [Video] Generative testing in Clojure

2014-01-01 Thread Mark Nutter
Nicely done, I've been looking for a good intro to generative testing. The
real-world example at the end nicely illustrates the value of the
shrinking part of the algorithm. Thanks for publishing this.


On Wed, Jan 1, 2014 at 10:58 AM, James Trunk james.tr...@gmail.com wrote:

 Hi everyone,

 Here is an introduction to generative testing in 
 Clojurehttp://www.youtube.com/watch?v=u0TkAw8QqrQ using
 simple-check.

 I hope newcomers to the technique/library find it useful!

 Cheers,
 James

 --
 --
 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.
 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 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/groups/opt_out.


-- 
-- 
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.
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 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/groups/opt_out.


Re: sending errors to the ui - web development using luminus

2013-08-10 Thread Mark Nutter
I am using Validateur (http://clojurevalidations.info/) as the basis for a
custom validation mechanism with Luminus. The validation-set fn gets you
about 90% of the way there: it takes a list of rules and returns a
function. Pass your data map to the function, and it returns a set of the
error messages. You can also write custom validation rules in case the
basic set isn't what you need.


On Fri, Aug 9, 2013 at 2:02 AM, Abraham abev...@gmail.com wrote:

 Dear
 How to send validate the input and then send all errors at a time .?
 I am using luminus , the doc shows send one error at a time.
 Thanks in advance
 A

  --
 --
 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.
 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 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/groups/opt_out.




-- 
-- 
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.
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 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/groups/opt_out.


Re: run-jetty not working in a virtualbox vm?

2013-07-13 Thread Mark Nutter
Not sure, but netstat -lanp as root might get you a more comprehensive
port listing. Sounds like you have a process still holding on to the port
somehow. As a last resort there's always killall java.


On Sat, Jul 13, 2013 at 7:27 AM, Daniel Higginbotham nonrecurs...@gmail.com
 wrote:

 Hmm, I tried using :join? true and that didn't seem to solve the
 problem. I was doing that so that I could start  the server in a repl if I
 wanted to and still use the repl.


 On Friday, July 12, 2013 10:29:04 PM UTC-4, Gareth Jones wrote:

 Just to check - you have set :join? false so the thread will not block
 until the server ends - are you doing this intentionally and blocking the
 thread elsewhere?


 On Fri, Jul 12, 2013 at 8:45 PM, Daniel Higginbotham nonrec...@gmail.com
  wrote:

 I'm trying to start a jetty server on a virtualbox vm (ubuntu 12.04 32
 bit) by running the following:

 (run-jetty #'app {:port (Integer. (get (System/getenv) PORT 8080))
 :join? false})

 However, I can't connect to the server. If I run netstat -lp the java
 process doesn't show up and it looks as if nothing's listening on 8080.
  However, if I run the above run-jetty function again in a separate process
 I get the error message that another process is already bound to 8080.

 The weirdest part of all this is that the very first time I tried
 starting the server, it did start and I was actually able to reach it, but
 it only worked that one time. Has anyone run into this? Is there any way to
 debug the problem?

 Thanks!
 Daniel

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@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+u...@**googlegroups.com

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://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+u...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .




  --
 --
 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.
 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 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/groups/opt_out.




-- 
-- 
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.
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 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/groups/opt_out.




Lambda Jam ticket available

2013-06-23 Thread Mark Nutter
Due to unexpected expenses, I'm going to be unable to use my early bird
ticket to Lambda Jam (July 8-10 in Chicago). I can't get a refund, but I
can designate a substitute if anyone's interested. Please contact me off
list if so.

Thanks.

Mark

-- 
-- 
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.
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 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/groups/opt_out.




Re: Screencast: Clojure development with Sublime Text 2

2013-05-21 Thread Mark Nutter
That's helpful for both clj and non-clj work, thanks.

Cygwin Sublime users might be interested in a quick little rc file I wrote
to let you use Unix paths with ST2 on the command line:

https://gist.github.com/manutter51/5608004

Just a bit OT, but I thought it might be of use to some ST/Clojure fans.


On Sat, May 18, 2013 at 4:36 PM, James MacAulay jmacau...@gmail.com wrote:

 This is a little show-and-tell I recorded today:

 http://www.youtube.com/watch?v=wBl0rYXQdGg

 Hopefully it's useful for some of you. Feedback welcome!

 Cheers,
 James

 --
 --
 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.
 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 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/groups/opt_out.




-- 
-- 
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.
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 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/groups/opt_out.




Re: Best IDE

2012-01-19 Thread Mark Nutter
On Thu, Jan 19, 2012 at 11:42 AM, David Brunell quantal...@gmail.com wrote:
 How long did it take you to get comfortable with paredit?  I keep getting
 frustrated and going back to manually matching parens.

I had the same experience for a while, but then I realized I just had
to remember 3 things:

To enclose an existing sexp inside a new one---in other words, if I
have (map...) and I want (doall (map...))---put the cursor on the
opening paren of the existing sexp and type M-( and it automatically
wraps the whole sexp in parens, correctly balanced.

To pull an existing sexp out of its enclosing sexp---i.e. to turn
(doall (map ...)) back into (map...)---put the cursor on the opening
paren of the inner sexp and type M-uparrow. Use with caution, because
it nukes anything else in the same enclosing sexp, but that's not too
bad because:

If you put the cursor on the opening paren and then hit C-k, it cuts
out exactly that sexp (and its contents) but no more, keeping the
parens perfectly balanced.

That last trick is what made paredit a must-have for me, because I do
a lot of cut and paste, and paredit makes it a piece of cake. You
don't have to worry about selecting the beginning and ending parens,
just put the cursor on the open paren and hit C-k, and it cuts exactly
as much as it needs to grab a balanced sexp, even across multiple
lines, leaving any other close-parens untouched. It's awesome.

I think paredit does other stuff too, but those three things get me
through the day.

Mark

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


Re: Clojure list syntax sugar: f(x) notation

2011-12-27 Thread Mark Nutter
I don't usually reply to this sort of thread, but I'll toss in two
cents worth anyway. Speaking as a PHP programmer wading his way
through the beginning-to-intermediate stages of Clojure, I have to say
that I do not like the proposed sugar. If I wanted to write PHP in
Clojure, I'd just write PHP, because I already know that. What Clojure
has that PHP lacks is an elegant simplicity to its syntax, which is a
direct result of its consistent treatment of parentheses. To introduce
new forms would unnecessarily complicate things and obscure this
fundamental consistency. If I see

   (foo thing)
   bar(other thing)

it looks to me like there should be some significant difference
between foo and bar, and how they are used. Syntactic sugar ought to
simplify difficult things, not complicate things that are already
simple. If we did have such sugar, I would think we ought to hide it
from beginners, so as to avoid confusing them unnecessarily. But then
what would be the point of having it?

Parens just aren't a big deal. Would HTML be easier to learn if we
wrote div instead of div? My kids can learn to write web
pages; I can't imagine an experienced programmer would really be all
that put off by the order of the first two symbols. If anything, it's
the nesting that's the real problem, and that's not really solved by
swapping the first ( and foo.

Sorry for being so negative--I do appreciate your good intentions, and
you do have a worthwhile goal. Also, it's just my personal opinion,
which doesn't count for much, so just take it for what it's worth.

m

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


Re: [ANN] Clojure 1.3 Released

2011-09-24 Thread Mark Nutter
Totally awesome, thanks to everyone.

I don't like the way github presents the changes.txt file, so I forked a
copy and did a teeny bit of markup tweaking so it will display in nice
touchy-feely HTML layout, if anyone is interested.

https://github.com/manutter51/Clojure-1.3-Changes-text/blob/master/README.creole

Cheers.

On Fri, Sep 23, 2011 at 5:44 PM, Christopher Redinger redin...@gmail.comwrote:

 We are pleased to announce today the release of Clojure 1.3:

   http://clojure.org/downloads

 For maven/leiningen users, your settings are now:

   :dependencies [[org.clojure/clojure 1.3.0]]

 This release includes many significant features and performance
 enhancements, documented here:

   https://github.com/clojure/clojure/blob/1.3.x/changes.txt



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

Re: clojurescript closure problem?

2011-09-22 Thread Mark Nutter
No, because that might not be what you want your code to do. As a JavaScript
programmer you have to understand what function scope means, and how to use
it appropriately. If hid is a variable that's in scope when you define an
anonymous function, your functions will refer to that specific variable. If
you define multiple anonymous functions in the same scope, they will
likewise all reference the same specific variable (and sometimes that's what
you want).  If you want each new anonymous function to have its own separate
variable named hid, then the way you tell the compiler what you want is by
wrapping another function around the code that generates your anonymous
function, and passing hid in as the argument to the wrapper function.
Having the compiler try and second-guess what it thinks you *meant* would be
bad, because someday some JavaScript programmer would try to share a
variable between multiple anonymous functions, and would be scratching their
head trying to figure out why the smart compiler was failing to obey the
rules of JavaScript function scope.

m

On Wed, Sep 21, 2011 at 2:34 PM, Eric Harris-Braun
zippy.314@gmail.comwrote:


 Shouldn't the clojurescript compiler detect that the usage of hid in
 the function in the first case requires the creation of an anonymous
 function to close around that value?  Why do I have to do it manually?



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

Re: clojurescript closure problem?

2011-09-22 Thread Mark Nutter
I stand corrected. I guess I'm *too* familiar with JS. I'll have to re-learn
a few things.

m

On Thu, Sep 22, 2011 at 8:34 AM, Meikel Brandmeyer (kotarak) 
m...@kotka.dewrote:

 Hi,

 Disclaimer: I haven't touched ClojureScript a single time up to now, I only
 know the talk of Rich about it. Neither am I JavaScript developer.

 Too me this smells like a bug. ClojureScript is not JavaScript. It tries to
 bring (where possible) Clojure semantics to the JavaScript VM. The first
 version is perfectly valid Clojure and I would be very surprised if this
 wouldn't work the same way in ClojureScript. If such radically different
 behaviour is to be expected, then I understood something seriously wrong
 about ClojureScript.

 In particular it kills sharing of clojure only libraries between both
 target platforms.

 Sincerely
 Meikel


  --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: newbie questions

2011-08-30 Thread Mark Nutter
There are some old Getting Started steps out there, but you'll
probably get a better start if you Google for leiningen and
swank-clojure for a more up-to-date technique.

If you need to tell the Clojure process to quit, the syntax is (System/exit 0).

Mark

On Tue, Aug 30, 2011 at 4:32 PM,  labwor...@gmail.com wrote:
 (1) I have followed the Getting started steps and installed clojure-mode
 in Emacs. However, when I edit a .clj file, I am in clojure-mode (C-h m) but
 no clojure on the menubar. There should be one, right? What am i missing.

 (2) I just use M-x inferior-lisp. But how do you get out of clojure? I tried
 (exit) or (quit) or .System.exit(0) but none worked.

 TIA

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: [ANN] clojure.java.jdbc 0.0.5 available

2011-07-20 Thread Mark Nutter
 * Add support for databases that cannot return generated keys (e.g., HSQLDB)
  - insert operations silently return the insert counts instead of
 generated keys
  - it is the user's responsibility to handle this if you're using
 such a database!

If I'm understanding this correctly, this means that inserting 4 rows
will return 4 instead of a list of 4 generated keys, is that right?
If so, what would you think about having it return a list of 4 zeroes
instead? It would still be up to the user to handle the zero as a
special case, but the structure would be more parallel with other db's
results, and you could test based on the key itself instead of
having to refer to some global *db-type* var for your if statement.

Mark

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


Re: another question on macros defining functions

2011-06-04 Thread Mark Nutter
Ok, so what you really want is not to change how your program
functions, but how your IDE/editor functions. That means what you
really want is not a clojure macro, but an emacs macro--you want to
extend the functionality of emacs to make your editing easier. The
clojure code you write is not going to achieve what you want (though
it may help you in learning how to write Emacs macros). I know enough
about elisp to customize it so that it throws error messages every
time I start it up, so I'll bow out here, but that's where you need to
go from here.

Cheers.

Mark

On Sat, Jun 4, 2011 at 1:15 AM, nil ache...@gmail.com wrote:
 Mark, it turns out that everything I need is known and static at hack-
 time. (Sorry for making it sound otherwise) I know all the names,
 values, *and* behaviors that I want to use when I'm writing the code
 for my tests. I just want my clojurebox symbol completion to work
 after having written a bunch of one-liners to declare families of
 functions. I think it forces me to eval certain files before I edit
 others. Am I making you all cringe?

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: another question on macros defining functions

2011-06-03 Thread Mark Nutter
I think you have the right idea, only not quite. :) If you write a
macro to define a function whose name is determined at run-time, you
end up with either a function that your program will never refer to,
or a program that calls functions that may or may not exist, depending
on what run-time values were passed to your macro. I don't think
that's really what you want. You want functions you can explicitly use
in your code while you are writing it, but you want the *behavior* of
those functions to be determined at runtime.

What I think you really want are anonymous functions assigned to named
vars--the function itself is generated at runtime and uses closures to
create the customized functionality you want, but you use the
generically-named vars to refer to them in your code. (Oops, I'm
saying vars and that may not be the right technical term in this
context--but you know what I mean.)

So for example, here's a factory function that takes an argument and
returns an anonymous function with your argument built-in:

(defn make-draw-fn [page field loc]
 (fn [offset-x offset-y]
   (let [gui (get-field page field loc)
         bounds (.getRect field)
         bounds (.addOffset offset-x offset-y)]
     (.doDraw gui bounds

The (let ...) form inside make-draw-fn does *not* execute when you
call make-draw-fn. The make-draw-fn merely *returns* a function that
will execute its body when you call it. What makes this particularly
useful is that when it does execute, it will remember the values of
page, field, and loc. In other words, you're creating a function at
runtime, and its behavior is customized by the runtime arguments you
pass it.

Then you make a page full of fields like this:

(let [page registration
      controls { :username (make-draw-fn page username id=Username)
                    :password (make-draw-fn page password id=Password)
                    ; ...
                   }]
   ((controls :username) 0 0)
   ((controls :password) 0 0)
   ; ...
)

This is really rough code (and my own noobishness is probably
showing), but I'm just trying to illustrate the general idea. By
making a factory function that returns anonymous functions, you create
closures that will remember any arguments passed to the factory.
This achieves the run-time customization you want to use macros for,
but without using a macro. Then you assign that anonymous function to
a variable of some kind, and call it by using the extra parentheses,
as in ((controls :password) 0 0).    I put the anonymous functions
in a hash map, but you could just as easily assign them to a var or a
list or anything else.

If you can get that working, but you find it's really annoying to
write the extra parentheses in ((controls :password) 0 0), *then*
you might want to consider writing a macro to expand (password 0 0)
into ((controls :password) 0 0). At that point you'll be good,
because you'll know all the names at the time you write your code, and
you won't have to mess with evals or anything.

HTH

Mark


On Fri, Jun 3, 2011 at 10:36 AM, nil ache...@gmail.com wrote:
 The problem here is that macros run at compile time, but let bindings
 exist at run time.

 If you need the name to be determined at run time you will need to use eval.

 Where do I use eval? I tried looking at the argument to see if it was
 called with a string literal vs a symbol, but can't eval a local:

 (defmacro foo [x]
  (let [name-as-string# (if (symbol? x) (eval x) x)
        name-as-symbol# (symbol name-as-string#)]
    `(defn ~name-as-symbol# [] (

 (let [eff gee] (foo eff))

 If you don't need the name at run time, why are you using (let [eff
 gee] (foo eff)) and not simply (foo gee)?

 I'm using let because I'd like to have the name at run time. I'm
 defining families of functions to manipulate types of UI elements by
 saying (type page-name field-name locator). Without knowing a solution
 to my problem, I'm stuck saying the following in order to generate a
 bunch of functions to use later in my program...

 (txt registration username id=Username)
 (txt registration password id=Password)
 (tog registration terms id=AcceptTerms)
 (nav registration submit //html/body/div/form/div/input /
 SignedIn)

 ... Instead of this:

 (let [page registration]
  (txt page username id=Username)
  (txt page password id=Password)
  (tog page terms id=AcceptTerms)
  (nav page submit //html/body/div/form/div/input /SignedIn))

 ... or interning page as a symbol that sticks around after I'm done
 with the definitions? Ew. Un-interning afterwards? Hm.

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

Re: newbie question

2011-04-19 Thread Mark Nutter
Hmm, in your example you say you're code looks like

(println hello)

but in your description you say

((println hello))

Don't know if that's a just a typo or not, but if you actually did
type in doubled parens like that it would give a null pointer
exception because println returns nil, which the extra parens would
try to execute as a function.

FWIW

On Mon, Apr 18, 2011 at 7:48 AM, lesni bleble lesni.ble...@gmail.com wrote:
 hello,

 i'm trying to start learning clojure with lein but i get into
 trouble.  I'm doing simple project:

 lein new foo
 cd foo
 lein deps
 echo '(println hello)'  src/foo/core.clj
 lein run -m foo.core
 hello
 Exception in thread main java.lang.NullPointerException
 (NO_SOURCE_FILE:1)
        at clojure.lang.Compiler.eval(Compiler.java:5440)
        at clojure.lang.Compiler.eval(Compiler.java:5415)
        at clojure.lang.Compiler.eval(Compiler.java:5391)
        at clojure.core$eval.invoke(core.clj:2382)
        at clojure.main$eval_opt.invoke(main.clj:235)
        at clojure.main$initialize.invoke(main.clj:254)
        at clojure.main$null_opt.invoke(main.clj:279)
        at clojure.main$main.doInvoke(main.clj:354)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.lang.Var.invoke(Var.java:369)
        at clojure.lang.AFn.applyToHelper(AFn.java:163)
        at clojure.lang.Var.applyTo(Var.java:482)
        at clojure.main.main(main.java:37)
 Caused by: java.lang.NullPointerException
        at user$eval13.invoke(NO_SOURCE_FILE:1)
        at clojure.lang.Compiler.eval(Compiler.java:5424)
        ... 12 more

 obviously my code ((println hello)) was executed followed by
 exception which i don't understand.  What is wrong?

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: (memoize) and recursive functions (Clojure 1.2)

2011-03-29 Thread Mark Nutter
I just saw this in another thread. Try this version instead:

(defn f [n]
  (println f called with n)
  (if (zero? n)
0
(min (#'f (dec n))
 (#'f (dec n)

What's happening is that inside the body of f, the f is a symbol
whose contents point to the anonymous function being defined, so when
you recurse, you're recursing to the original anonymous function, not
the current value of f. By using the #' macro in front of the f,
you're saying Use the current value of the symbol f to calculate the
following value.

On Mon, Mar 28, 2011 at 8:47 PM, Benny Tsai benny.t...@gmail.com wrote:
 I was playing with memoize when I ran into some puzzling behavior.  A test
 case:

 (defn f [n]
   (println f called with n)
   (if (zero? n)
     0
     (min (f (dec n))
          (f (dec n)
 (def f (memoize f))

 *The usage of def to rebind a function to its memoized version is taken
 from Programming Clojure.

 The output when I call f with 2:

 user= (f 2)
 f called with 2
 f called with 1
 f called with 0
 f called with 0
 f called with 1
 f called with 0
 f called with 0
 0

 Since f is memoized, my expectation was that I would see f called with 2,
 f called with 1, f called with 0 each printed just once.  Instead, it's
 as though I didn't memoize f at all.  I know I did, because if I call f with
 2 again, I get 0 back right away.

 user= (f 2)
 0
 This leads me to the second issue: Having evaluated (f 2), I assumed that
 the results for (f 2), (f 1), and (f 0) are all now available for immediate
 retrieval.  If I call (f 3), I thought I would only see f called with 3
 printed and then the result.  Instead, this is what I saw:

 user= (f 3)
 f called with 3
 f called with 2
 f called with 1
 f called with 0
 f called with 0
 f called with 1
 f called with 0
 f called with 0
 f called with 2
 f called with 1
 f called with 0
 f called with 0
 f called with 1
 f called with 0
 f called with 0
 0

 It's as though the recursive calls go to the unmemoized version of the
 function instead of the memoized one.

 I did find a way to get the expected behavior:

 (def g
   (memoize
    (fn [n]
      (println g called with n)
      (if (zero? n)
        0
        (min (g (dec n))
             (g (dec n)))

 user= (g 2)
 g called with 2
 g called with 1
 g called with 0
 0
 user= (g 3)
 g called with 3
 0

 Up until now, I assumed the first formulation would work with recursive
 functions as well.  Was that incorrect?  Is something like the second
 formulation the only way to memoize recursive functions?

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: bindings lazy-seq

2011-03-26 Thread Mark Nutter
I'll take a stab at this and then someone can tell me if I'm
understanding it myself.

 (lazy-seq
  (binding [*in* in#]
-- some code --))

This is inside the definition, so it executes whenever you actually
USE the definition--i.e. it binds *in* to in# at the time the lazy seq
is used, which is probably what you want.

 (binding [*in* in#]
  (lazy-seq
-- some code --))

This is outside the definition, so it executes and binds *in* to in#
at the time the lazy seq is defined. In other words, the binding ends
as soon as the lazy seq is defined, so when you go to actually use the
seq, the binding has ended, and *in* has its original value.

How'd I do?

On Fri, Mar 25, 2011 at 7:47 AM, Carlos-K cap...@gmail.com wrote:
 Hi,

 Why when you create a lazy sequence, you need to do the bindings
 inside the definition?, e.g.,

 (lazy-seq
  (binding [*in* in#]
    -- some code --))

 As opposed to make the bindings first and call the lazy-seq later,
 e.g.,

 (binding [*in* in#]
  (lazy-seq
    -- some code --))


 Thanks

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Grabbing Rotten Tomatoes movie ratings in clojure

2011-01-19 Thread Mark Nutter
Let me also recommend swannodette's excellent Enlive tutorial:

https://github.com/swannodette/enlive-tutorial

It's a great way to jump into the meat and potatoes.

m

On Tue, Jan 18, 2011 at 7:05 PM, justinhj justi...@gmail.com wrote:
 Thanks for the feedback Stuart

 I'll check out Enliven. I'm currently writing an app using Compojure,
 Ring and Hiccup, so it would fit nicely with that too by the sound of
 it.


 On Jan 16, 7:25 pm, Stuart Campbell stu...@harto.org wrote:
 Hi,

 Have you used Enlive[1]? It's a nice tool for HTML scraping and templating -
 it might be more robust than your regexp-based solution. It takes a bit of
 learning, though.

 Regards,
 Stuart

 [1]https://github.com/cgrand/enlive

 On 16 January 2011 05:57, justinhj justi...@gmail.com wrote:







  Sharing my first useful Clojure program. Feedback welcome.

 http://bit.ly/clojure-rotten-tomatoes

   --
  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.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@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 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 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Wildcards on multimethod matching

2010-10-25 Thread Mark Nutter
 So in this particular case I wouldn't care, but in general I'd expect
 the prefer-method stuff to kick in. :)

Oops, forgot about prefer-method. My noobishness is showing again.
Well, in for a dime in for a dollar. Here's something I whipped up
just for the general amusement of the list. It's not quite what you
asked for, but it might be suitable as a source of ideas, instruction,
derision, or whatever.

(defmulti bar (fn [x y  more] [x y]))
(defmethod bar :default [x y  more]
  (if more ; did default loop back to itself?
nil
(some identity [(bar :wild y x)
  (bar x :wild y)])))
(defmethod bar [:wild 16] [x-wild y  more]
  (let [x (first more)]
(str First arg wild  x ,  y)))
(defmethod bar [42 :wild] [x y-wild  more]
  (let [y (first more)]
(str Second arg wild  x ,  y)))
(defmethod bar [10 20] [x y]
  (pr-str Plain vanilla args  x ,  y))

user (bar 10 20)
\Plain vanilla args \ 10 \, \ 20
user (bar 42 20)
Second arg wild 42, 20
user (bar 10 16)
First arg wild 10, 16
user (bar 42 16)
First arg wild 42, 16user (bar 10 20)
\Plain vanilla args \ 10 \, \ 20
user (bar 42 20)
Second arg wild 42, 20
user (bar 10 16)
First arg wild 10, 16
user (bar 42 16)
First arg wild 42, 16

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


Re: Newbie: Exceptions and map

2010-10-15 Thread Mark Nutter
Map returns a lazy seq (which I suspect you already knew). Try it with
doall instead of do. The do only wraps the map expression, it
doesn't actually realize the seq.

On Fri, Oct 15, 2010 at 11:39 AM, bleibmoritztreu jlewa...@uos.de wrote:
 Hi group,

 I'm playing around with Clojure for a few weeks now and quite like it.
 Today however I noticed one thing which puzzles me a lot, and maybe
 points at something very basic I've misunderstood, so I wanted to ask
 here:

 Why doesn't
 (do (map #(throw (Exception. %)) '(a)) true)
 throw any Exception?

 It seems to me that it is because of the combination of do and map,
 since they alone behave like I would expect:

 (map #(throw (Exception. %)) '(a))
 throws an Exception and so does
 (do (throw (Exception. a) true)

 Does anybody have a good explanation for me?

 Thanks a lot,

 Jirka


 P.S.: Sorry, I have submitted this post in an incomplete version a few
 minutes ago...

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: java interop problem

2010-09-13 Thread Mark Nutter
The REPL automatically realizes the lazy sequence in the process of
printing it out, but if you try to us

On Mon, Sep 13, 2010 at 11:07 AM, Ranjit rjcha...@gmail.com wrote:
 Thanks Armando for catching my stupid mistake. That fixed everything.

 Meikel, I'm not sure I understand what you're saying. When I evaluate
 this in the REPL

 (for [x (range 2) y (range 2)] (aset xt x y (+ x y)))
 (aget xt 0 0)
 (aget xt 1 1)

 I get back 0 and 2 as I expect. Isn't the call to aset consuming the
 lazy sequence?

 Thanks.

 On Sep 13, 11:00 am, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 On 13 Sep., 15:07, Ranjit Chacko rjcha...@gmail.com wrote:

      (for [x (range 3) y (range 3)] (aset xt x y 1))

 Note that that this will not do what you think it does. for creates a
 lazy sequence which is thrown away immediately. So the aset calls are
 never done. for is a list comprehension, not a looping construct.
 Replace for with doseq. As a rule of thumb: side-effects = command
 starting in do.

 Sincerely
 Meikel

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: java interop problem

2010-09-13 Thread Mark Nutter
Erg, gmail hiccup. Started to say if you try to use it in code that's
*not* being called from the REPL, you'll be scratching your head
trying to figure out why aset never gets called.

Mark

On Mon, Sep 13, 2010 at 12:27 PM, Mark Nutter manutte...@gmail.com wrote:
 The REPL automatically realizes the lazy sequence in the process of
 printing it out, but if you try to us

 On Mon, Sep 13, 2010 at 11:07 AM, Ranjit rjcha...@gmail.com wrote:
 Thanks Armando for catching my stupid mistake. That fixed everything.

 Meikel, I'm not sure I understand what you're saying. When I evaluate
 this in the REPL

 (for [x (range 2) y (range 2)] (aset xt x y (+ x y)))
 (aget xt 0 0)
 (aget xt 1 1)

 I get back 0 and 2 as I expect. Isn't the call to aset consuming the
 lazy sequence?

 Thanks.

 On Sep 13, 11:00 am, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 On 13 Sep., 15:07, Ranjit Chacko rjcha...@gmail.com wrote:

      (for [x (range 3) y (range 3)] (aset xt x y 1))

 Note that that this will not do what you think it does. for creates a
 lazy sequence which is thrown away immediately. So the aset calls are
 never done. for is a list comprehension, not a looping construct.
 Replace for with doseq. As a rule of thumb: side-effects = command
 starting in do.

 Sincerely
 Meikel

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Quirk of Map destructuring

2010-09-13 Thread Mark Nutter
On Mon, Sep 13, 2010 at 12:37 PM, Tom Hicks hickstoh...@gmail.com wrote:

 On Sep 12, 10:44 pm, Meikel Brandmeyer m...@kotka.de wrote:

 The default map specifies the default for the symbols which are bound,
 not the source of the values.

 (let [{foo :some-key bar some-other-key :or {foo 1}} ] ...)

 Sorry Meikel, I don't understand your answer. My question was why does
 the
 default map not lookup the values using the same lookup method as the
 original map (:keys, :strs, or :syms)? Why does it always assume
 symbols for keys?

What he's saying is that the map after the :or is not doing a lookup
in the original map you're destructuring, so it's not a question of
doing the same kind of lookup or not. The map after the :or is a map
of local symbols to default values (as opposed to being a map of
keys-found-in-the-original-map to default values.

(let [foo bar] ...)
Assigns the value of bar to the local symbol foo

(let [{:keys [foo]} {:foo bar}] ...)
Assigns the string bar to the local symbol foo by looking up the
keyword :foo in the supplied map

(let[{:keys [foo baz] :or {baz quux}} {:foo bar}]...)
The tricky bit: it looks up the key :foo in the supplied map, and
creates a local symbol foo with the value bar. Next, it looks up
the keyword :baz (which is nil) and creates a local symbol named baz
that is also nil. At this point, it's done looking things up in the
supplied map. Now we're up to the :or part. For each local symbol with
a nil value, we look in the :or map to see if there's a key with the
same symbol. If there is, we use that as the value of the local symbol
instead of nil. But the point is we're looking up local symbols now,
not anything in the original map.

Caveat: that's a high-level overview from a fairly new Clojure user
(me) who is only attempting to rephrase what he thinks he's understood
from reading the words of people who know what they're talking about.
The source code for :or destructuring may use a different process
completely, or I may have been more or less correct. I don't really
know, but if I've mangled anything I'm hopeful someone will correct
me.

Cheers.

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


Re: clojure.contrib.trace not working on 1.2?

2010-09-08 Thread Mark Nutter
I seem to recall that 1.2 is using chunked lazy sequences for
performance reasons, and fib is a lazy sequence. I wonder if you'd
start seeing intermediate steps using (fib 20) instead of (fib 3)?

m

On Tue, Sep 7, 2010 at 7:32 PM, Scott Jaderholm jaderh...@gmail.com wrote:
 Why does c.c.trace give different output on 1.2 than it did on 1.1?

 From 
 http://learnclojure.blogspot.com/2010/02/slime-2009-10-31-user-defn-fib-n-if-n-2.html

 On 1.1

 user (dotrace (fib) (fib 3))

 TRACE t1880: (fib 3)
 TRACE t1881: |    (fib 2)
 TRACE t1882: |    |    (fib 1)
 TRACE t1882: |    |    = 1
 TRACE t1883: |    |    (fib 0)
 TRACE t1883: |    |    = 0
 TRACE t1881: |    = 1
 TRACE t1884: |    (fib 1)
 TRACE t1884: |    = 1
 TRACE t1880: = 2
 2
 user

 On 1.2

 user dotrace (fib) (fib 3))

 TRACE t11624: (fib 3)
 TRACE t11624: = 2

 Thanks,
 Scott

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: agents, await and Swing thread

2010-09-07 Thread Mark Nutter
Just a quick thought (and before I've had my coffee no less!), but I
think what I'd do is replace the boolean *end-search* with a
*search-state* var that could be either :idle, :running or :stopping.
Then in search-stops, just set *search-state* to :stopping -- you
don't need to actually wait for the agents to finish, you just need to
know that the current condition is waiting for the search to end so
you don't quit the app or start a new search until the cleanup is
finished. Then when you do hit some task that needs to wait until the
agents are done, you can go ahead and await the agents (i.e. if you're
quitting and it doesn't matter if there's a hang), or spawn a thread
that will await the agents before starting the new search. You could
also run a cleanup thread that would check the state of your search
agents and set the *search-state* from :stopping back to :idle once
all the search agents had finished.

Mark

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


Re: trouble with NetBeans install

2010-08-30 Thread Mark Nutter
This may or may not be related, but I had similar problems when I
tried to install from the downloadable .nbm file for enclojure. I
solved it by poking around the enclojure.org site -- there's
instructions for updating the plugins setup screen so that you can
install/update enclojure using the built-in automatic install/upgrade
interface. I can give you more information if that's close but not
quite enough.

Mark

On Mon, Aug 30, 2010 at 9:04 AM, Stuart Halloway
stuart.hallo...@gmail.com wrote:
 A student in the upcoming Clojure Studio is reporting the following problem 
 getting started with NetBeans. Any suggestions?

 Some plugins require plugin Common Scripting Language API (new) to be 
 installed.
 The plugin Common Scripting Language API (new) is requested in version = 
 1.9.1.1.1.1.1 (release version 1) but only 2.5.1.2.1.1.4 (of release 
 version different from 1) was found.  The following plugin is affected:     
   Clojure Plugin
 Some plugins require plugin Editor Library to be installed.
 The plugin Editor Library is requested in version = 1.38.1.9.2 (release 
 version 1) but only 2.10.2.10.2 (of release version different from 1) was 
 found.  The following plugin is affected:       Clojure Plugin
 Some plugins require plugin org.netbeans.modules.templates to be installed.
 The plugin org.netbeans.modules.templates is requested in version 1.4.1.  
 The following plugin is affected:       Clojure Plugin  Some plugins not 
 installed to avoid potential installation problems.

 Thanks,
 Stu

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: java.lang.OutOfMemoryError

2010-07-27 Thread Mark Nutter
On Mon, Jul 26, 2010 at 9:53 AM, atucker agjf.tuc...@googlemail.com wrote:
 Here is my function:
 (defn json-seq []
  (apply concat
         (map #(do (print f) (str/split (slurp %) #\nStatusJSONImpl))
              out-files)))

Try removing the apply concat at the front, I'm pretty sure that's
making your sequence non-lazy.

Mark

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


Re: enclojure install killed netbeans 6.8

2010-03-10 Thread Mark Nutter
I haven't tried removing the entire 6.8 directory (except in
conjunction with a complete reinstall of NetBeans), so I can't say
whether that should or should not work, but I have manually removed
the enclojure plugin via deleting the clojure-specific files and that
has gotten me out of a few jams. Beyond that I'm out of tricks.

Good luck.

Mark

On Wed, Mar 10, 2010 at 3:55 PM, strattonbrazil
strattonbra...@gmail.com wrote:
 No, I moved the entire 6.8 directory out of .netbeans and it still
 didn't run.  You still think I should focus on getting rid of just the
 clojure files?  Netbeans can't just rebuild that directory seeing as
 it's not there anymore?

 Josh

 On Mar 9, 2:01 pm, Mark Nutter manutte...@gmail.com wrote:
 On Sun, Mar 7, 2010 at 6:44 PM, strattonbrazil strattonbra...@gmail.com 
 wrote:
  I am on Linux.  I have a 6.6 and a 6.8 directory in my .netbeans
  folder.  6.6 still runs.  I have tried moving individual jars in and
  out of that dir, but I still get the error.  I even moved the entire
  6.8 dir and still get the same message.

 There's more than just jar files involved -- some of the .xml config
 files contain pointers that tell NetBeans to try to load whatever
 library it is that you are missing. If you want to completely remove
 the plugin, you need to get rid of all the clojure-related files in
 the .netbeans/6.8 directory. You can use the find command to locate
 them:

 $ find ~/.netbeans -name '*cloj*' -print

 Mark

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: enclojure install killed netbeans 6.8

2010-03-09 Thread Mark Nutter
On Sun, Mar 7, 2010 at 6:44 PM, strattonbrazil strattonbra...@gmail.com wrote:
 I am on Linux.  I have a 6.6 and a 6.8 directory in my .netbeans
 folder.  6.6 still runs.  I have tried moving individual jars in and
 out of that dir, but I still get the error.  I even moved the entire
 6.8 dir and still get the same message.

There's more than just jar files involved -- some of the .xml config
files contain pointers that tell NetBeans to try to load whatever
library it is that you are missing. If you want to completely remove
the plugin, you need to get rid of all the clojure-related files in
the .netbeans/6.8 directory. You can use the find command to locate
them:

$ find ~/.netbeans -name '*cloj*' -print

Mark

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


Re: Leiningen, Clojure and libraries: what am I missing?

2010-03-07 Thread Mark Nutter
On Sun, Mar 7, 2010 at 10:40 AM, Meikel Brandmeyer m...@kotka.de wrote:

 So your point boils down to emacs and lein don't work on Windows. I
 don't know about emacs, but at least for leiningen there is some
 activity at that front (cf. Rob's response).

 So I still think: if you have trouble with clojure and Windows, you are
 probably using the wrong tools.

I wrestled with trying to set up emacs and clojure under Windows, but
quickly gave up on trying to do it all by hand and just downloaded
Clojure Box (http://clojure.bighugh.com/), which was about as painless
as I could hope for. I'm still getting my toes wet in Clojure, though,
and have only used it for trying out quick ideas and doing little
quickie tutorial type problems, so I can't say how well it would work
for more industrial-sized projects.

Mark

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


Re: enclojure install killed netbeans 6.8

2010-03-07 Thread Mark Nutter
On Fri, Mar 5, 2010 at 11:34 PM, strattonbrazil
strattonbra...@gmail.com wrote:
 Has anyone had problems with netbeans starting with the enclojure
 alpha?  I restarted my session and it died.  Now when I try to run
 netbeans, it throws a classpath exception.  Can I remove this plugin
 or am I missing something in my install?

First of all, do you have the JavaSE module installed and activated in
NetBeans? That's a piece that will definitely crash your IDE if you
try running Clojure without it.

If you need to uninstall the plugin in order to reinstall everything,
and if you're under Linux, look in the .netbeans directory in your
home directory for any file containing '*cloj*' and I think you'll see
pretty quickly where the plugin files are.

$ find ~/.netbeans -name '*cloj*' -print

Not sure where the Windows equivalents live, but if you need help with
that let me know and I can find out.

Mark

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


Re: Enclojure plugin Netbeans

2010-02-24 Thread Mark Nutter
I think I know this one: you need NetBeans with the Java module
activated. I had the same problems trying to use NetBeans with just
PHP.

Mark

On Wed, Feb 24, 2010 at 8:18 AM, Larry Wykel lwy...@earthlink.net wrote:
 Anyone!!!

 .

 Anyway if your using Enclojure etc in Netbeans let me describe exactly what 
 happens when I attempt to install plugin

        Latest MacOS Snow Leopard
        NetBeans 6.8 with just Ruby
        Enclojure plugin from Git

        File came down with a .zip extention



        1. I renamed the file to same name with .nbm extension

        2. Went into Netbeans plugin manager.downloads and added the file. I 
 found it
                and it showed up fine  and I could click the install button.

        3. the process then runs and it loads when its done ti gave me no 
 choice to restart it just restarted Netbeans.

        4. Netbeans closed and restarted but when it came back up the Menu was 
 gone except for Netbeans prefs and
                the Netbeans Icon was in the Dock.

        5. When you attempt to open clicking on the Icon does nothing. You 
 cannot even git rid of it.
                I actually go into the Activity monitor and kill the Netbeans 
 process, then remove Netbeans and reinstall.

        6. When I do Netbeans comes up fine and shows the Enclojure plugin 
 installed. But you cannot activate it.

        Just wanted to let you know if quickly looking at these iissues you 
 know what the problem is or can suggest something

 I am sure the plugin will do what I am after fro now once I get it activated.

 Lar

 --
 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.
 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 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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Neophyte question

2009-10-21 Thread Mark Nutter

Hi all, newcomer to clojure/lisp/fp here. I'm working my way through
the Programming Clojure book (very excellent, well worth the money),
and doing some dabbling in the REPL, and I'm seeing something that
puzzles me. In the book there's an example of a clojure blank?
function that looks like this:

(defn blank? [s] (every? #(Character/isWhitespace %) s))

So far so good. I want to use that sort of pattern to define a hex?
function to see if a string is all hexadecimal characters. (Not that I
need a hex? function, I just want to see if I can write it.)

I start with a hexchar? function to test individual characters.


user= (defn hexchar? [c] (re-find #[0-9A-Fa-f] c))
#'user/hexchar?
nil
user= (hexchar? a)
a
nil
user= (hexchar? w)
nil
nil


Ok, so far so good. Now I want to use this function to define hex?,
using the pattern from Programming Clojure


user= (defn hex? [s] (every? #(hexchar? %) s))
#'user/hex?
nil
user= (hex? a)
#CompilerException java.lang.ClassCastException: java.lang.Character
cannot be cast to java.lang.CharSequence (NO_SOURCE_FILE:0)


Not what I expected at all! I assume there's a problem with the result
returned by re-find? Not sure. I'm going to keep playing with it, but
in the meantime I thought I'd post what I'm seeing in case somebody
wanted to shed some light on the subject. This is from the Netbeans
REPL provided by the enclojure plugin by the way.

Thanks for any clues you have to share.

Mark

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



Re: Neophyte question

2009-10-21 Thread Mark Nutter

Thanks, all, that's enlightening. So if I understand correctly, I
designed hexchar? to accept a string argument, which means it needed a
CharSequence, right? But instead it was getting a Char, which is not
the same thing as a one-character string, and thus was not a
CharSequence.

Yahrgh, I've been working in PHP the last few years, it's giving me
bad habits. Bad mental habits, worse yet. But it's coming back to me.

Thanks again.

m

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