Re: Mapping first element only: how to preserve vectors

2012-03-20 Thread Rasmus Svensson
On Mon, Mar 19, 2012 at 2:40 PM, Bojan bojandoli...@hotmail.com wrote: Hi! I'm a beginner at clojure and enjoying the learning process. While writing my first nontrivial program, I noticed that I'm transforming only first elements in the list, so I factored this transformation out by writing

Re: Accessing vals in clojure.lang.PersistentVector

2012-01-25 Thread Rasmus Svensson
On Wed, Jan 25, 2012 at 10:45 AM, Simon Holgate simon.holg...@gmail.com wrote: I've retrieved some data from my database which is returned as a clojure.lang.PersistentVector: org.psmsl.netcdf.core res [{:name BREST, :time #Date 1807-01-01, :rlrdata 6882M} {:name BREST, :time #Date 1807-02-01,

Re: strange problem

2012-01-17 Thread Rasmus Svensson
Den 16 januari 2012 16:58 skrev joachim joachim.de.be...@gmail.com: However, when I try the same in an emacs repl, I get  Lisp connection closed unexpectedly: connection broken by remote peer. I have no idea what is going on or how to deal with this problem. Sometimes during development I like

Re: Problem with Greeks!

2011-08-17 Thread Rasmus Svensson
. the Encoding Guy at your service, Rasmus Svensson (raek) -- 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

Re: Spitting out a lazy seq to file???

2011-08-16 Thread Rasmus Svensson
2011/8/16 Thomas th.vanderv...@gmail.com: Hi everyone, I have been struggling with this, hopefully, simple problem now for quite sometime, What I want to do is: *) read a file line by line *) modify each line *) write it back to a different file This is a bit of sample code that

Re: Being able to use blank?

2011-07-21 Thread Rasmus Svensson
2011/7/21 octopusgrabbus octopusgrab...@gmail.com: Thanks. You're right. (:require [clojure.contrib.string :as cstr]) ; str already defined There should be no conflict between the var str (clojure.core/str) and the namespace alias str (clojure.string). Names for vars and namespaces never occur

Re: Namespace Docstrings?

2011-07-15 Thread Rasmus Svensson
2011/7/14 OGINO Masanori masanori.og...@gmail.com: Hello. What is the right way to display namespace docstrings? One day, as usual, I typed: (doc 'clojure.core) ; or other namespace Then the REPL said clojure.lang.Cons cannot be cast to clojure.lang.Symbol. I thought Ah, I know, the

Re: Clojure and swedish characters on windows...

2011-06-20 Thread Rasmus Svensson
are opened with the default encoding, which I believe you set with the file.encoding property. // Rasmus Svensson (raek) -- 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

Re: using regex reader macro with generated code

2011-06-16 Thread Rasmus Svensson
into string syntax. If you happen to want to serialize this object later (e.g. print it at the repl or dump it to a text file), this regex object will print as an ordinary regex literal. * Using syntax-quote is probably more ideomatic here. // Rasmus Svensson (raek) -- You received this message

Re: ClojureBox on Window 7: classpath in .emacs file not working

2011-06-12 Thread Rasmus Svensson
. Let me know if something in my instructions does not work, or if you have other questions. // Rasmus Svensson (raek) -- 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

Re: Parsing HTML in clojure

2011-06-06 Thread Rasmus Svensson
2011/6/6 Base basselh...@gmail.com: hi all, I am working on an app that will parse web pages to do some NLP and statistics.  I am able to parse the HTML using several different tool ( enlive, HTML parser, etc).  However I would like to discard all the rest of the junk in the web page that is

Re: Parameterizing project.clj

2011-05-23 Thread Rasmus Svensson
expressions directly after the tildes, but I wanted to demonstrate the possibility of using def here. Hope this helps! // Rasmus Svensson (raek) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure

Re: (just) emacs mode

2011-04-27 Thread Rasmus Svensson
2011/4/27 John V johnv02...@gmail.com: Hi, I would like to have syntax highlighting for Clojure code in Emacs.  I am using Emacs on Windows (23.2.1).  I found this page: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs ... but it was clearly much more involved than I was looking

Re: (just) emacs mode

2011-04-27 Thread Rasmus Svensson
2011/4/27 John V johnv02...@gmail.com: Hi, I would like to have syntax highlighting for Clojure code in Emacs.  I am using Emacs on Windows (23.2.1).  I found this page: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs ... but it was clearly much more involved than I was looking

Re: help--reading keyboard input from Clojure is surprisingly difficult

2011-04-08 Thread Rasmus Svensson
See this tread for why stdin is not directly available with lein: http://groups.google.com/group/leiningen/browse_thread/thread/f9f9ed97eb8a2928/ccab95588ef50d05?lnk=gstq=stdin This is currently impossible due to a bug in ant; it just swallows stdin completely, and they seem to have no intention

Re: Newbie: General question about concurrency in Clojure

2011-03-09 Thread Rasmus Svensson
The answer would be a mix of A and B, mostly because there seems to be an assumption that you have to consider concurrency everywhere in order to be able to have it at some point later. This is not the case. You do tend to be very explicit about concurrency and only use the concurrency primitives

Re: Better Workflow with App Engine?

2011-02-16 Thread Rasmus Svensson
2011/2/15 Thorsten Wilms t...@freenet.de: Hi! I managed to get to a Hello world level using appengine-magic, plus an Emacs Swank/Slime setup. I haven't used appengine-magic myself, but I do interactive web programming from Emacs (mainly using Ring + Moustache + Enlive), so I thought I'd share

Re: Better Workflow with App Engine?

2011-02-16 Thread Rasmus Svensson
P.S. I forgot to mention that a lot of really useful slime commands are documented at the swank-clojure project site: https://github.com/technomancy/swank-clojure // raek -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Re: clojure.contrib.condition

2011-02-14 Thread Rasmus Svensson
2011/2/8 Brian Marick mar...@exampler.com: The header documentation for clojure.contrib.condition says:     Note: requires AOT compilation. What do I therefore do differently? How should my program text change? The clojure-contrib jar file that your build tool - or yourself, if you do stuff

Re: Handling of unsigned bytes

2011-02-13 Thread Rasmus Svensson
To turn a signed byte (-128 to 127) into an unsigned one: (bit-and the-byte 0xff) The byte (for example 0x80, which is negative) will be extended to an int (0xff80) and anded with 0x00ff (and you get 0x0080, which is positive). The javadoc for the methods of DataInput[1] contain

Re: How does pmap partition its work?

2011-01-27 Thread Rasmus Svensson
2011/1/24 Michael Gardner gardne...@gmail.com: Suppose I have a sequence of tasks I'd like to parallelize using pmap. The amount of CPU time these tasks require varies greatly; in particular, many of them will require virtually no work. Can I rely on pmap to divide the work efficiently even

Re: How does pmap partition its work?

2011-01-27 Thread Rasmus Svensson
2011/1/27 Ken Wesson kwess...@gmail.com: On Thu, Jan 27, 2011 at 2:09 PM, Michael Gardner gardne...@gmail.com wrote: On Jan 27, 2011, at 7:24 AM, Rasmus Svensson wrote: If you simply want all tasks to be performed as quickly as possible, one alternative could be to use an ExecutorService

Re: Why does (.foo (new Bar)) use a different method invocation mechanism than (def bar (new Bar)) (.foo bar)?

2011-01-16 Thread Rasmus Svensson
2011/1/16 Robert Campbell rrc...@gmail.com: The second form - (.foo bar), expanded to (. bar foo) - eventually calls Reflector.invokeNoArgInstanceMember. For that form, the clojure compiler cannot infer the type of bar, and does not know which exact method (class + type signature) .foo

Re: Queues in Clojure

2010-12-03 Thread Rasmus Svensson
2010/12/3 Andreas Kostler andreas.koestler.le...@gmail.com: Hi All, May I cite an Author of a populer Clojure book: If you find yourself wishing yourself to repeatedly check a work queue to see if there's an item of work to be popped off, or if you want to use a queue to send a task to

Re: priority queue for scheduling events in the future

2010-11-24 Thread Rasmus Svensson
2010/11/24 HiHeelHottie hiheelhot...@gmail.com: Does anybody know of an implementation for a priority queue that can be used for scheduling events in the future?  I would like to put a map associated with a timestamp into the queue and be able to pull out all maps at or before a given time in

Re: println from within a thread

2010-11-21 Thread Rasmus Svensson
2010/11/21 HiHeelHottie hiheelhot...@gmail.com: Does anybody know how to redirect the output into the repl? Thread local bindings are not passed on to new threads. Since you might have multiple connections to the swank server, there might me multiple repls, each one with their own *out*. Most

Re: string interpolation

2010-11-21 Thread Rasmus Svensson
2010/11/21 HiHeelHottie hiheelhot...@gmail.com: I think ruby has nice string interpolation.  You can put the following in a textfield that a user can modify This is a #{adjective} string. Then, you can take that string, put it in quotes and have ruby evaluate it as a string.  What is the

Re: REQUEST for feedback on http://clojure.org

2010-11-11 Thread Rasmus Svensson
I also noticed that clojure.org/agents does not mention the *agent* var... // raek -- 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

Re: Jython Interoperability problem

2010-11-09 Thread Rasmus Svensson
2010/10/29 Dilvan dil...@gmail.com:   Any clues? I don't know much about how Jython works, but from the stack trace it seems like Clojure cannot load its source files from the classpath. Are there other ways to add jars to the classpath in Jython? // raek -- You received this message because

Re: Jython Interoperability problem

2010-11-09 Thread Rasmus Svensson
It seems like this is a class loader issue... The guys working on clojure-ant-tasks seems to have hit the same problem: https://github.com/jmcconnell/clojure-ant-tasks/issues#issue/5/comment/223478 I also found these two issues: http://dev.clojure.org/jira/browse/CLJ-260

Re: - related error in clojure 1.2

2010-11-09 Thread Rasmus Svensson
2010/11/9 Carlos Moscoso moscoso@gmail.com: user= (- {:a 1} (keyword a)) - is simply a code rewrite macro. You can use macroexpand-1 to see how the rewrite is done: user= (macroexpand-1 '(- {:a 1} (keyword a))) (keyword {:a 1} a) As Sunil said, you can get the desired behaviour by adding

Re: How to rewrite code to avoid bashing transients in-place?

2010-11-08 Thread Rasmus Svensson
2010/11/9 Greg g...@kinostudios.com: I think to answer both questions I should explain the context of this problem. I'm currently in the process of learning Clojure, and as an ex cerise to assist in this endeavor I set about solving a problem presented in the classic game called Myst. One of

Re: How to rewrite code to avoid bashing transients in-place?

2010-11-08 Thread Rasmus Svensson
For fun, I made my own code for proving your result: https://gist.github.com/668830 (contains? (reachable-states [3 3 3]) [2 2 1]) = false //raek -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Documentation lacking for ns macro

2010-11-05 Thread Rasmus Svensson
2010/11/4 Ken Wesson kwess...@gmail.com: The ns macro seems to be poorly documented as yet. The Namespaces page at the main Clojure site does not go into detail about its syntax; Yes. The docs related to the ns form are indeed insufficient and need attention. However, have you seen the

Re: REQUEST for feedback on http://clojure.org

2010-11-05 Thread Rasmus Svensson
I think there should be a link from the Namespaces page to the Libs page. Hopefully, this will make it easier for people to find examples on how to use the ns form. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: figuring out sets

2010-11-02 Thread Rasmus Svensson
2010/11/1 tonyl celtich...@gmail.com: I was wondering since it uses the dispatch macro and AFAIK there is no api fn to create them like hash-maps to create maps, vector/vec for vectors, or list for lists. There are parallels to 'hash-map' and 'sorted-map' in the api: user= (hash-set :a :b :c)

Re: Can't locate str_utils in classpath

2010-11-02 Thread Rasmus Svensson
2010/10/31 Steven Arnold thoth.amon.i...@gmail.com: Hello, I am trying to use the str-utils library with Clojure (or the str-utils2, I understand str-utils was deprecated).  Neither of these work for me.  I am on OS X 10.6.4 and have installed clojure-contrib via the MacPorts system.  The

Re: [Bug] StackOverflowError while using map inside a reduce

2010-11-02 Thread Rasmus Svensson
2010/11/3 John Szakmeister j...@szakmeister.net: I'm sorry... I don't quite understand this explanation.  Do you mean that reduce is realizing the entire list all at once?  I would think it would grab an element one at a time.  Sorry for the stupid question, but there's something subtle here

Linköping Clojure User Group Startup Meeting

2010-09-24 Thread Rasmus Svensson
Hi Clojurians of Linköping! This is an invitation for the upcoming startup meeting of a new Clojure group in Linköping. On 29th of September (next Wednesday), Linköping Clojure User Group will have its first meeting. (Those of you who hang around in House B at the University may have already

Re: Clojure meetup group listing

2010-09-24 Thread Rasmus Svensson
2010/9/20 Andrew Gwozdziewycz apg...@gmail.com: I'd like to propose that we make an effort to list these groups on Meetup Everywhere (http://www.meetup.com/everywhere), which is a free platform useful for finding a nearby meetup about a given topic. Hi! Linköping Clojure User Group will have

Re: clojure.string

2010-09-24 Thread Rasmus Svensson
2010/9/24 cej38 junkerme...@gmail.com: I noticed that clojure.string is not showing up on the API webpage, http://clojure.github.com/clojure/, is that an oversight? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Re: Byte Literals

2010-09-23 Thread Rasmus Svensson
There's also 'bytes', 'byte-array' and 'into-array': (byte-array (map byte [1 2 3])) (into-array Byte/TYPE (map byte [1 2 3])) // raek -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note

Re: trouble getting library structure right: can't let files talk to each other

2010-08-17 Thread Rasmus Svensson
2010/8/17 jandot jan.ae...@gmail.com: Hi all, I'm trying to write a library to perform some statistical and data mining analyses. Clojure has proven a great help here, especially with the incanter library. Writing the code has been kind of an organic process (read: no planning), and I ended

Re: Clojure Web Programming group?

2010-08-17 Thread Rasmus Svensson
I think there's a lot of questions that a Clojure programmer faces when doing web programming, not only regarding how the libraries work, but also regarding how to design a larger-than-trivial web applications. A mail list would be a very good way to be able to ask for advice or to be inspired by

Re: multiline strings and multiline comments ?

2010-08-16 Thread Rasmus Svensson
2. multiline comments like java /* this is a   multiline comment */ I don't know. Comment blocks are usually done by starting each line with ;; ;; this is ;; a comment ;; block (some-code) Anything after a ; is a comment, like python's #. There is a convention for how many ;s to begin

Re: Trouble upgrading to clojure 1.2

2010-08-16 Thread Rasmus Svensson
2010/8/16 Alan a...@malloys.org: I hear that swank.core/break has more functionality in 1.2, so I am trying to upgrade to it, but I think I don't have a clear enough understanding of what is going on when lein/clojure run, as I am running into problems. $ cat project.clj (defproject ddsolve

Re: chinese character in hiccup

2010-08-12 Thread Rasmus Svensson
2010/8/12 James Reeves jree...@weavejester.com: On 12 August 2010 14:33, limux liumengji...@gmail.com wrote: The solution in http://tiny.cc/3cmrx is useful, thanks. That what cause the issue should be compojure. That thread's time is 6, June. and compjure haven't fixed it. The solution you

Re: Eclipse and Compojure

2010-08-10 Thread Rasmus Svensson
I assume the problem is that there are no .class files in the jar. I tried to rebuild the compojure jar using lein jar but still didn't get .class files, even though: Clojure looks for both .class files and .clj files, so you don't need to compile anything manually. I'm seeing the following

Re: chinese character in hiccup

2010-08-10 Thread Rasmus Svensson
2010/8/10 limux liumengji...@gmail.com: There is some chinese chararters in the tables. I want to display them by hiccup, but browser display those chinese character as ???. I spoke to him on #clojure and from what I could tell from some experiments I asked him to run: (map int 刘孟江) - (21016

Re: chinese character in hiccup

2010-08-10 Thread Rasmus Svensson
I looked into the source of hiccup and tried entering the string 刘孟江 at various places, but I couldn't reproduce the error or find any code that did any form of encoding. When playing around with the repl, I was reminded that JLine (used by lein repl) does not support multibyte encodings

Re: Can't get my nesting right

2010-08-10 Thread Rasmus Svensson
2010/8/10 Alan a...@malloys.org: I have the following function as part of a card-game system I'm developing: (defn make-suit  [suit owner ranks]    {suit (map (partial struct-map card                        :suit suit                        :owner owner                        :rank)      

Re: abstract structural binding

2010-08-01 Thread Rasmus Svensson
2010/8/1 doug 395curra...@gmail.com Hey all! can't seem to get the last element to bind. tia -doug user cj-mpdata [0010335602 40.00 1060.51 6/23/2010 DISCOVER E- PAYMENT 7796 (DISCOVER)] user (let [[[_ ck db cr _ dt _ _ _][dsc]] [[Acct Chk Debt Crd Bal Date Desc

Re: Question on namespace/packages of defrecord

2010-07-17 Thread Rasmus Svensson
2010/7/17 Moritz Ulrich ulrich.mor...@googlemail.com clojure-namespaces should be treated like java-namespaces: (ns foo.bar) instead of (ns foo-bar) I think he refered to the fact that the hyphen in the (single) namespace segment was not translated into an underscore. // raek -- You

Re: Clojure 1.2: Unicode string length bug?

2010-07-04 Thread Rasmus Svensson
This is most probably a repl-terminal encoding mismatch issue. Are you using JLine? It seems to be the case that it cannot handle UTF-8. There is a simple way to see if there is encoding mismatch issues: just make a seq of the string: (seq t) if everything is working correctly: = a seq of the 9

Re: classpath and require

2010-06-19 Thread Rasmus Svensson
2010/6/18 Mohammad Khan beepl...@gmail.com C:\Projects.cljjava -cp c:\clojure-contrib\clojure-contrib.jar;c:\clojure\clojure.jar clojure.main Clojure 1.1.0-alpha-SNAPSHOT user= (require 'examples.introduction) java.io.FileNotFoundException: Could not locate examples/introduction__init.class

Re: code review request: clojure.java.io

2010-06-18 Thread Rasmus Svensson
2010/5/11 Stuart Halloway stuart.hallo...@gmail.com Assembla Ticket #311 [1] calls for the promotion of clojure.contrib.iointo clojure (as clojure.java.io). I have attached a patch, and am requesting comments and code review from the community. I think I have found a bug in the

Re: agents sending-off to other agents blocks?

2010-06-16 Thread Rasmus Svensson
2010/6/12 Dan Larkin d...@danlarkin.org Does anyone have insight as to the reasoning here? Is it a bug? If it's intended behavior is there something I can do to circumvent it? I do think this is intentional. Agents holding on to their sends until its state transition function is done can be

Re: special forms

2010-05-20 Thread Rasmus Svensson
I thought I'd just share some thoughts on special forms... 2010/5/20 Konrad Hinsen konrad.hin...@fastmail.net You can't redefine special forms. What you define in your examples is the symbols that serve to identify special forms. But they indicate special forms only when used in the first

Re: Clojure Cheat Sheet

2009-10-20 Thread Rasmus Svensson
2009/10/19 Gorsal s...@tewebs.com: All right, so this is probably way off topic, but what software was used to create the clojure cheat sheet? http://clojure.org/cheatsheet I really like the format and would like to make one for my own utilities so that I can actually remember what general