Re: "Soft" failures with spec?

2017-02-18 Thread Linus Ericsson
There is a good talk by Chris Houser, "Condition Systems in an Exceptional Language" [1] where he systematically goes through many of the aspects on handling exceptions in batch processing (like the problem Josh describes). An interesting way to build a conditional error handler is outlined towa

Re: Clojure.spec, maps, restrict valid keywords, easier way?

2017-02-03 Thread Linus Ericsson
It would be great if an editor highlighted a (possibly qualified) keyword that was used only in that particular place (given all code loaded). This wouldn't be bullet-proof, but would have highlighted mistakes like :encypted (but could still confuse :encrypted? with :encrypted, and whatnot). /

Re: Streamlining dev environment startup

2015-12-01 Thread Linus Ericsson
You can hardcode the nrepl-server port with :repl-options {:port 4001} as seen at [1]. When thinking about it, maybe you could script tmux or similar to show all running terminals at once, like shown in [2]. [1] https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L354 [2]

Re: om next quickstart

2015-11-29 Thread Linus Ericsson
The problem here seems to be it can't find the dependency. Can you do lein clean lein repl and then try (require '[figwheel-sidecar.repl :as r]) (require '[figwheel-sidecar.repl-api :as ra]) to begin with? Because it seems like it cannot get the dependencies right for some reason. What does

Re: How to move an element within a vector?

2015-08-26 Thread Linus Ericsson
It is correct that vectors aren't a suitable choice for datastructures that need "random-access-removal". The problem is that you seem to need both fast index lookup and be able to access elements "after" removed elements quickly even when there are holes in the backing array. There are some so

Re: some guidance sought

2015-08-10 Thread Linus Ericsson
The clojure core datastructures PersistentHashMap and PersistentVector are based on Philip Bagwells Ideal Hash Trees: http://lampwww.epfl.ch/papers/idealhashtrees.pdf Several of Chris Okasakis Purely Functional Datastructures are implemented already. http://www.cs.cmu.edu/~rwh/theses/okasaki.pd

Re: #{:rant} Questions about contribution policy and clojure compiler source.

2015-07-18 Thread Linus Ericsson
Hotline Combi 450 Mobile Telephone Den 19 jul 2015 02:56 skrev "Fluid Dynamics" : > On Saturday, July 18, 2015 at 8:22:35 PM UTC-4, Linus Ericsson wrote: > >> >> In cases like these I would strongly suggest Zach, Kyle and the Clojure >> Core-team to strive to

Re: #{:rant} Questions about contribution policy and clojure compiler source.

2015-07-18 Thread Linus Ericsson
It is sad that Zach and Kyle thinks they spent time in vain. Clojure is less about code and more about holistic considerations and intentions than most other software projects. Jira (and mail chains such as this) are probably the worst possible hammers on communicating intentions and more holis

Re: clojure.core.match: AssertionError: Pattern row reuses wildcards

2015-07-02 Thread Linus Ericsson
Use the :tx-data as a $-database! The only pitfall is that the second position, the attribute, and all other references (reference type) is just a reference to the attribute entity (a long). Let's say you find :db/txInstant to be 53, and :community/category to be 112 the query would look like

Re: Testing and infrastructure management for large Clojure app - how are you doing it?

2014-10-29 Thread Linus Ericsson
I really cant see how the testers could NOT be able to use a repl to do some exploratory testing. Clojure's strength is really that you can align the code very closely to the domain, although this modelling is (as always) challenging. And the application logic does not have to be tested through a

Re: Modelling in Clojure

2014-10-22 Thread Linus Ericsson
Jason, the summary is good, but I'm missing the more efficient data structure array-map that probably wastes less space than the hash-map for the same size of object. [1] Also Zach Tellman has made some effort with clj-tuple which however use indexes, not keys. [2] [1] http://clojuredocs.org/clo

Re: agent validation fails in STM

2014-10-18 Thread Linus Ericsson
You are right! If, say, a file write, fails the data would reside only in your memory refs. One way to make sure the two thing are always in sync is to be able to rollback the in-memory state (and replaying all subsequent actions) by holding on to the old version until the agent could be derefed

Re: Adding up numbers, quickly

2014-10-15 Thread Linus Ericsson
There are primitive vectors. Extraordinary clever. http://clojuredocs.org/clojure.core/vector-of /Linus Den 16 okt 2014 00:02 skrev "Jony Hudson" : > Thanks, that's really useful! > > > Jony > > > On Wednesday, 15 October 2014 20:53:40 UTC+1, Jony Hudson wrote: >> >> Hi all, >> >> another perfo

Re: Calling the main static method of a class

2014-09-26 Thread Linus Ericsson
You can set system properties with System/setProperty. See more here: http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html /Linus Den 26 sep 2014 15:58 skrev : > hi, > > I've got a "traditional" java class invoked from the command line: > > public class Aclass > > public s

Re: reading to learn and acquire the skill of writing optinal Clojure code

2014-09-26 Thread Linus Ericsson
Andy, I would go for quantity over quality here. There's really a lot of libraries but only some applications (where I think LightTable is one of the most polished applications). Don't miss the quite good catalogue http://www.clojure-toolbox.com/ some things are a bit outdated, but it doesn't mat

Re: How do I track down a painfully long pause in a small web app?

2014-09-14 Thread Linus Ericsson
If you turn on verbose gc for the JVM you could at least rule out GC pauses. Hmm, exactly how do you route the requests through the apache server? It almost sounds like your applikation is restarted every now and then, iirc Apache only servers a limited amount of requests per server thread. If th

Re: Pause a go loop

2014-09-11 Thread Linus Ericsson
For instance you can use schejulure [1] or at-at [2] and make sure the scheduled function calls put an item (event) on the channel and then made the scheduler do the pausing work. All the "listeners" attached to the channel will receive the events at the time the scheduler "releases" them, and you

Re: [ANN] Clojure 1.7.0-alpha2

2014-09-11 Thread Linus Ericsson
The volatile construct seems very useful in some particular cases! I have been missing "ugly-mutable" variables for things such as certain types of heaps/queues or write-intensive, slightly probabilistic stuff where one missed write doesn't matter that much. For people who don't have a Java backgr

Re: HTTP server that supports ring handlers, but asynchronously?

2014-09-03 Thread Linus Ericsson
Pedestal pedestal-service handles requests asynchronously by extending the ring standard with Interceptors, sort of a state machine queue version the wrapped handlers of ring. /Linus Den 3 sep 2014 10:35 skrev "Laurens Van Houtven" <_...@lvh.io>: > Hi James, > > Thanks for your response! Replies

Re: clojure streams

2014-08-29 Thread Linus Ericsson
(Rich Hickey is the only one who could answer finally but...) I think this information is old and outdated, streams didn't really make it into clojure. The things that survived was the *sequence* abstraction (which is used almost everywhere), later the *reducers* (facilitating javas fork-join con

Re: setrlimit from Clojure

2014-08-20 Thread Linus Ericsson
According to this [1] post one can reachything in Glibc with JNA. I have never tried. /Linus [1] http://unix.stackexchange.com/questions/1681/invoke-syscalls-from-java On Wednesday, August 20, 2014, Chai Tadada wrote: > Hello, > > Is it possible to call the setrlimit syscall on Unix (I want to

Re: Is Clojure a language for growth?

2014-08-20 Thread Linus Ericsson
Well, for better or worse we don't like conflicts that much. This has benefits when it comes to some kinds of problem solving (the way to consensus in Swedish companies is worth at least a chapter in a big book about antrophology). This shyness for open conflicts can lead to stagnation. This means

Re: Benchmarking structural sharing

2014-08-12 Thread Linus Ericsson
You could likely use System/identityHashCode to count the similarity of objects all the objects. I created a small function that only honors the "clojure-visible" structure, and exposes every item in a tree structure (apart from the arrays in PersistentVectors and some PersistentMaps) (defn steam

Re: A more general case of some->?

2014-07-21 Thread Linus Ericsson
Check out pedestals interceptors, they handle both error and pause/resume-request functionality. Seems you could have great use of it. Pedestal-service is the repo. pedestal.io /Linus On Monday, July 21, 2014, Leon Grapenthin wrote: > The predicate parameter introduces an additional predicate

Re: An Averaging function

2014-07-10 Thread Linus Ericsson
You should try Clojure Programming (Halloway, Bedra). I felt enlightened after reading the first edition, the second edition is also very good! http://pragprog.com/book/shcloj2/programming-clojure /Linus On Thursday, July 10, 2014, Stephen Feyrer wrote: > Hi Sam, Lee. > > Thank you both. > > I

Re: OT: Github Alternatives

2014-06-30 Thread Linus Ericsson
gitolite? I think we used it on one of my jobs. https://github.com/sitaramc/gitolite /Linus On Monday, June 30, 2014, Di Xu wrote: > gitlab[1]? > > ​[1]​ https://about.gitlab.com/ > > > 2014-06-30 18:34 GMT+08:00 Adrian Mowat >: > >> Hi All, >> >> Sorry for the off topic thread but my company

Re: lazy list comprehension

2014-06-27 Thread Linus Ericsson
You probably want map-indexed http://clojuredocs.org/clojure_core/1.2.0/clojure.core/map-indexed /L 2014-06-27 17:10 GMT+02:00 Leonardo Borges : > Try using map : > > (map str '(my-list-of-crap) (iterate inc 0)) > > -- > You received this message because you are subscribed to the Google > Grou

Re: When to use (ensue) ?

2014-06-26 Thread Linus Ericsson
See points 2, 3 and 8 at http://clojure.org/refs It is just a way to obtain the "change lock" of the ref in the dosync transaction, without rewriting it. The alternative would be to explicitly modify it to the same value as it was before, which is potentially wasteful. One possible case where thi

Re: Understanding when compilation occurs - for function producing functions

2014-06-21 Thread Linus Ericsson
On Saturday, June 21, 2014, Di Xu wrote: > Suppose at my REPL I do... >> >> (defn direct-report-oneplustwo [] (println (str "Direct one plus two is " >> ((fn [n] (+ 1 n)) 2) "."))) >> >> ...then I presume that the compiler has compiled my >> direct-report-oneplustwo function, and that this has in

Re: BeagleBone Black Continuous Analog Reads

2014-06-18 Thread Linus Ericsson
I would say it's not so much about programming paradigm rather than system calls. It all boils down to how often you would want to read the data. If it's not more than some times per second, and it's not super important with timing, you could probably put a reading function in a SchedulingThreadPo

Re: time expression of clojure produces different results on cascalog queries

2014-06-14 Thread Linus Ericsson
It says Criterium ran four batches of 60 samples in each (it tries to make the jvm då garbage collection etc between each such batch). In total, 240 samples (ie timed test runs). The statistics are better looked up at wikipedia, but "lower quartile" here means the 2.5% of the 240 samples (0.025 *

Re: using "hidden" parameters?

2014-06-14 Thread Linus Ericsson
A more commonly used feature are bindings, which are sort of "pluggable" (or rather overridable) dynamic vars. http://stackoverflow.com/questions/1523240/let-vs-binding-in-clojure In short you declare a variable as dynamic and then use some binding around the function-call. Sort of a reusable le

Re: Use Nodejs modules in Clojurescript code that targets browsers?

2014-06-09 Thread Linus Ericsson
Yes, by using externs: http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html A bit dated, but I think this is still the way to go! /Linus 2014-06-08 6:36 GMT+02:00 Gabrien : > Is there any way to use nodejs modules (the browserifiable ones) in > Clojurescript code that

Re: Advice on managing random number generators across threads

2014-06-06 Thread Linus Ericsson
(I think your stepwise problem is better to be solved without agents, see below.) I realized that the *rng* actually is conflated, it keeps both the state for the random number generator AND the algorithm used for the random number generation. This is usually not a problem, since the state-size an

Re: Past and future of data.generators

2014-06-05 Thread Linus Ericsson
I do agree that the name data.generators is not where to look for a controllable random source. A more specific name for these functions should be considered. The java.util.Random has been an issue for me in stress-testing random read and writes to a huge memory-area by several threads. If I was t

Re: use :only in ns

2014-06-04 Thread Linus Ericsson
Either :use with [seesaw.chooser :only [choose-file]] like (ns ... (:gen-class) (:use [seesaw.chooser :only [choose-file]]) or the beefed up refer functionality: http://clojuredocs.org/clojure_core/clojure.core/refer which can have :only, :exclude and :rename to avoid collisions, which

Re: Allow reseeding/rebinding RNG behind rand?

2014-06-04 Thread Linus Ericsson
Sorry, of course i meant the clojure.data.generators library https://github.com/clojure/data.generators esp. the *rnd* that can be bound around many of the functions in the library. /Linus On Wednesday, June 4, 2014, Linus Ericsson wrote: > Data.generative already has this function and m

Re: Allow reseeding/rebinding RNG behind rand?

2014-06-04 Thread Linus Ericsson
Data.generative already has this function and many more, I realized. /Linus On Wednesday, June 4, 2014, Mars0i wrote: > > > On Wednesday, June 4, 2014 2:55:20 AM UTC-5, Gunnar Völkel wrote: >> >> Once you notice that you usually need a fast solution. >> > > Yes! > > >> The easiest solution is t

Re: Search seqs in seqs

2014-06-03 Thread Linus Ericsson
Maybe reduce-fsm could be useful? https://github.com/cdorrat/reduce-fsm It creates a simple state finite state machine that can be applied on any sequence. /Linus 2014-06-03 11:04 GMT+02:00 Ulrich Küttler : > Hi, > > what is the preferred way to find sub-seqs in a seq? I am trying to convert

Re: Is it the right Clojure group for a newbie

2014-06-02 Thread Linus Ericsson
Also check out Kyle Kingsbury's Clojure from the ground up: http://aphyr.com/posts/301-clojure-from-the-ground-up-welcome A lot of things in Clojure gets much easier when one understands a bit of java. Not how to write a for loop, but rather how to use various classes. I recommend the Oracle Java

Re: Short tutorials on ClojureScript

2012-11-07 Thread Linus Ericsson
This looks really promising. One question: when one builds modern-cljs, is there any extra configuration needed for getting the clojurescript compiler up and running? I get a "java.lang.String cannot be cast to clojure.lang.Associative" when doing $ lein buildcljs once, which I don't really know w

Re: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-29 Thread Linus Ericsson
or to increase a counter while reducing it, a function like inc+ returning {:sum sum :count count} and then take the sum/counter, which is the mean. The problem is possible to state as a clean map-reduce problem with only one traversing of the data. It's also possible to remove items form the mean

Re: A New Core.logic Primer

2012-03-14 Thread Linus Ericsson
2012/3/14 David Nolen > On Wed, Mar 14, 2012 at 4:09 PM, Daniel Gagnon wrote: > >> >> >> On Wed, Mar 14, 2012 at 3:00 PM, David Nolen wrote: >> >>> Thanks to Edmund Jackson we have a new primer for core.logic: >>> https://github.com/clojure/core.logic/wiki/A-Core.logic-Primer >>> >>> Feedback app

Re: datomic has been announced

2012-03-05 Thread Linus Ericsson
Mindblowing! I can imagine many applications for datomic, it looks like a very powerful abstraction which is overcoming many of the problems I've been encountering when I've built applications. Thanks, Rich! Chris Grangers awesome experimental UI for developing javascript games is covered in Wired

Re: [clojurescript one] Where does Clojurescript One come from?

2012-02-28 Thread Linus Ericsson
The rationale for Clojurescript is available here: https://github.com/clojure/clojurescript/wiki/Rationale I would say it's a way to wrap the large possibilities of javascript in a saner and quite well known environment for Clojurians. The way to use the Google Closure libs+compiler is very clever

Re: notes on Mathematica pattern transformation & Clojure predicate dispatch

2012-02-23 Thread Linus Ericsson
2012/2/23 Cedric Greevey > On Thu, Feb 23, 2012 at 2:41 PM, kovas boguta > wrote: > > In general the way repl's handle state is pretty busted. > > > > Ever create a piece of data and then later wonder, how the heck did I > make this? > > One simple thing would be if the repl logged sessions to >

Re: ns :import / reflection

2012-02-21 Thread Linus Ericsson
Wrong type of parens! This works for me: (ns test (:import [java.io File])) it's a bit of a gotcha, though. /Linus On 2/18/12 10:29 PM, ClusterCat wrote: > Hello, > I have two newbie questions: > > First > - > (ns test (:import (java.io File))) > > I can use File like this > (let [file (Fi

Re: Newbie to Clojure..

2012-02-18 Thread Linus Ericsson
Nazar, I don't know what you mean by "Intelligent" but please checkout WebNoir [1] for a quick way of building web applications in Clojure. If you are into rich web applications (ie clever client side) ClojureScriptOne [2] also might be an option for you. To just get started with the language (w

Re: noob question/request for guidance vis a vis connecting to SQL Server

2012-02-17 Thread Linus Ericsson
Hi! Long way! To start with I would head for using webnoir+korma for starters. I think its a better lighted up road for people to start with (eventually you could dump the jvm after a while and run everything in node.js or something but for now thats a risky road for someone new to the language IM

Re: Lack in the documentation

2012-02-17 Thread Linus Ericsson
A treasure! I will from now on start to jot down whatever I do also. /Linus 2012/2/16 Sean Neilan > Of course, I won't be able to write the entire Recipe Book by myself. I > will contribute all the recipes I have discovered with test cases. > > On Thu, Feb 16, 2012 at 11:40 AM, Sean Neilan wr

Re: Lack in the documentation

2012-02-16 Thread Linus Ericsson
Regarding don't want to learn Java. I understand fully, but can I suggest downloading a major java-IDE and make some small and simple java-katas in it? I would suggest IntelliJ IDEAs Community Edition (there are other, ofc) and then going through some examples from the surprisingly well written Ja

Re: Need help to translate a simple java program into Clojure program

2012-01-09 Thread Linus Ericsson
2012/1/9 Nicolas Garcin > Hello, > > I'm new to functional programming and Clojure and I'm trying to > translate a simple java program into Clojure. My program must build > from 2 input lists (stored in a vector) 2 output lists (also stored in > a vector) which have same number of elements as inp

Templating, how to?

2012-01-09 Thread Linus Ericsson
I want to generate rules with constant and/or functions producing parts of the rules: (defn rulemaker [] (str "SCOPE " global-constant ";" (some-global-function) ";")) which could be called with (with-super-closure model-in-file-reference (rulemaker)) Is there a way to make some "tempora

Re: Any char-based Java file I/O with arbitrary seek?

2012-01-05 Thread Linus Ericsson
How about a memory mapped file? Not lazy at all, but could be quick, given that you have enough memory. http://docs.oracle.com/javase/1.4.2/docs/api/java/nio/MappedByteBuffer.html There can be times where a database is too low performant or clumsy for quick searching in a large utf-8 file, but so

Re: Use You a Spaced Repetition System for Great Good!

2012-01-03 Thread Linus Ericsson
Hi Joshua! I've been using Anki for repeating unsorted Clojure-stuff in about a year. It's good for knowing all the instructions and source code, but the key to success is always to solve more or less complicated problems (4clojure.orgetc). On the practical side I have a lot left to learn, also si

Re: Literate programming/TDD with Leiningen + midje + marginalia

2011-12-22 Thread Linus Ericsson
Yes, it does. I had problems with some midje-facts crashing the rendering in marginalia, but was able to just give the files as consecutive arguments as a work around. lein marg src/app/core.clj src/app/another/file.clj wildcards works fine as well. This problem with midje-facts being incompatib

Mechanism for escaping of predefined entities missing in clojure.xml

2011-12-22 Thread Linus Ericsson
Hi! I have been in the wondrous world of XML-parsing last week and I've found a missing mechanism in clojure.xml - the escaping the predefined entities: Example: (use 'clojure.xml) (def xmlelem (parse (new org.xml.sax.InputSource (new java.io.StringReader "" ;; parsing string xmlelem ;;

Re: Ranged types

2011-12-21 Thread Linus Ericsson
2011/12/21 Marek Kubica > Hi, > > Thanks for your mail, glad to get ideas so fast :) > > On Wed, 21 Dec 2011 09:51:04 +0100 > Linus Ericsson wrote: > > > I would def a protocol CustomArithmetics and include the the > > nescessary methods for arithmetics, and t

Re: Ranged types

2011-12-21 Thread Linus Ericsson
Hi Marek! I would def a protocol CustomArithmetics and include the the nescessary methods for arithmetics, and then a deftype for each custom arithmetics. It would be possible to extend the protocol for Longs and Integers as well, if needed. If you would like to use the normal operator-names +,-

Re: ANN: core.memoize v0.5.1

2011-12-14 Thread Linus Ericsson
Wov! There have been some great and very educational blog posts on how to improve the memoization functionality for various use-cases but this makes it even more effort free to use the techniques. This is brilliant! Thank you! /Linus 2011/12/14 Fogus > core.memoize v0.5.1 Release Notes >

Re: xml-zip

2011-12-13 Thread Linus Ericsson
(defn get-all-dimensions [] > (doseq [id (xml-> mz zf/descendants (attr= :id "2") zf/children :e > (attr :id))] >(println (apply str id > > > Note that I had to make a couple of fixes to the above XML to make it > right. > > I hope that's useful! >

xml-zip

2011-12-12 Thread Linus Ericsson
Hello! What's the clever way to read the E-tags "thisone" and "andthis" in the XML-file below given I don't know their id on beforehand? bla bla bla bla My solution so far would be something like (def mz (zip/xml-zip (xml/parse "dataabove.xml")

Re: Trying to use CDT on 1.3.0

2011-12-09 Thread Linus Ericsson
Swank is not built in by default. Have you added a :dev-dependencies [[swank-clojure "1.4.0-SNAPSHOT"]] map entry to project.clj and runned lein deps and the lein swank? (1.4.0-SNAPSHOT worked for me a few days ago, maybe 1.4.0 is out sooner or later) /Linus 2011/12/9 Richard "Tiger" Melville

Re: Unexpected behaviour in unchecked-multiply when using vars as arguments

2011-12-05 Thread Linus Ericsson
Thats a great feature as well! It is very good not to clutter the code with magic constants, but to be able to name them in a sane way. Thank you all again, /Linus Den 5 dec 2011 18:38 skrev "David Powell" : > > > On Mon, Dec 5, 2011 at 5:29 PM, Linus Ericsson < > osc

Re: Unexpected behaviour in unchecked-multiply when using vars as arguments

2011-12-05 Thread Linus Ericsson
David and Stu to the rescue. Of course that's the way to do it. Thank you both, /Linus 2011/12/5 David Nolen > You can't store primitives in vars. But you can cast their contents to > primitives with (long ...) (int ...) etc > > David > > On Mon, Dec 5, 2011

Re: Unexpected behaviour in unchecked-multiply when using vars as arguments

2011-12-05 Thread Linus Ericsson
2011/12/5 Stuart Sierra > > (side note: what is different between Long/MAX_VALUE and the > > function call (Long/MAX_VALUE)? > > None. Both are syntax sugar for (. Long MAX_VALUE) > > > > It seems like unchecked-multiply doesn't like vars, but thats surprising. > > What am I doing wrong here? >

Unexpected behaviour in unchecked-multiply when using vars as arguments

2011-12-04 Thread Linus Ericsson
I try to do multiplication where overflowing is expected and the result should be handled "modulo" ie the multiplication results in a truncated long. user> (unchecked-multiply (Long/MAX_VALUE) (Long/MAX_VALUE)) 1 ;;is ok and expected also classificator.fnvhash> (unchecked-multiply Long/MAX_VALUE

Re: How would you model this data?

2011-12-03 Thread Linus Ericsson
I don't know what data the vectors depict, but if they are like floating point numbers and you want to do distances etc (like geodata), and need high performance on various strange matchings you should consider something like R-trees http://en.wikipedia.org/wiki/R-tree (or check if there is some

Re: Avout: Distributed State in Clojure

2011-11-30 Thread Linus Ericsson
In Clojure in Action (still in MEAP i think) there's a chapter about using (Erlang/OTP-based) RabbitMQ message queue server for making Clojure scalable in a Hadoopish map-reduce-way. Avout seems to solve many of the problems that easily could occur in such an approach by not needing a centralized

Re: Proper parallelism?

2011-11-22 Thread Linus Ericsson
There's an approach using agents described here: http://travis-whitton.blogspot.com/2009/07/network-sweeping-with-clojure.html It's a bit old, so somethings in the example could be a bit outdated, but the idea may help you forward, /Linus 2011/11/22 AndyK > I have been using Clojure to write

Re: All subsets of a vector

2011-11-09 Thread Linus Ericsson
(map #(vec (take (inc %) a1)) (range (count a1))) does it the lovely map. /Linus 2011/11/9 Shoeb Bhinderwala > Is there a more elegant/idomatic way to achieve the following result: > > user=> a1 > ["a" "b" "c" "d"] > > user=> (map-indexed (fn [n x] (vec (take (inc n) x))) (take (count a1) > (r

Re: Nested Syntax Quote, Quote and unquote example

2011-10-31 Thread Linus Ericsson
"No one can be told what the matrix is." Well, the best way to understand the macros is to try it out yourself. John Lawrence Aspden published some really helpful tutorials om macros, and a kata - try it! Links in the end. There are some other code examples around, also look in the source-code of

Re: Losing your head with side effects

2011-10-25 Thread Linus Ericsson
Range is lazy. First you define a range, which is just a "promise" that the variable will be rendering a seq with 10M when asked for the elements. When you count the sequence you realize it and it takes up much space. When you let go if it it's of course GCed. The problem is that you hold on to

Re: Swarming experiment at Conj?

2011-09-21 Thread Linus Ericsson
Would it be possible to store the original defn s-expression source code in metadata added to the java byte-code function? It would be highly inefficient (and most of the time meaningless) for autogenerated functions, but quite a small overhead for the few locs a developer spits out during a hack-

Re: Example of a real-world ClojureScript web application

2011-08-11 Thread Linus Ericsson
You get Selenium running by using the clj-webdriver [1], thanks to Semperos for that one! [1] https://github.com/semperos/clj-webdriver /Linus 2011/8/11 Filip de Waard > On Thu, Aug 11, 2011 at 4:03 AM, Timothy Washington wrote: > >> Good on you. I've been looking to find a reliable way to hav

Re: Tree vaadin?

2011-06-26 Thread Linus Ericsson
Maybe (map #(.addItem tree (.toString (first %))) planets) where #(.addItem tree (.toString (first %))) should be replaced with the correct java interop for inserting into the tree, and the % becomes one and one of the items in the planets vector (that is regarded as a sequence) the argument. /L

Variable types changes over namespaces

2011-04-08 Thread Linus Ericsson
I find this behaviour a little surprising: --foo/core.clj: (ns foo.core (:require [foo.bar :as test])) (def ark (test/a-var test/another-var)) --foo/bar.clj: (ns foo.bar) (def a-var {:animal "dog"}) (def another-var {animal: "cat"}) REPL: in the repl I get: foo.core> (map class ark) => (cl

Re: Need some help with static files and ring...

2010-10-18 Thread Linus Ericsson
This tutorial covers the subject pretty well, I assume you've already read it. http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html according to it you should use "Next, include the necessary Ring middleware: (:use ring.middleware.file) (:use ring.middleware.file-info

Re: Fighting with Emacs ;-)

2010-09-27 Thread Linus Ericsson
I recognize that one. The repl haven't loaded the file your editing. My (temporary) solution is to do a (load-file "") after each edit that I want to debug, but that's a bit boring. I guess there is some kind of reload feature somewhere... /Linus 2010/9/27 psfblair > I found the old thread bel

Re: How often do you use REPL?

2010-09-27 Thread Linus Ericsson
Why not? The only thing I found very practical (even though it does not yet work 100% (like autoloading the open code in the repl) for me) is the possibility to fire of longer commands and function definitions (or the like) in Slime (or vi-equivalent). The repl is a great way to debug your though

Re: Extending Clojure's STM with external transactions

2010-09-02 Thread Linus Ericsson
Persistant variable handling is one of the things which I have spent much time on as a beginner and former SQL-illiterate (Among getting the swank to finally work (it's a dream!)). I have however got into databases quite a bit among the way - but it was not my main goal and it has taken some time f

Somnium.congomongo missing contribs json

2010-08-30 Thread Linus Ericsson
I have problems loading somnium.congomongo. My Leiningen project.clj looks like this: (defproject system1 "0.1.0" :description "System1" :dependencies [ [org.clojure/clojure "1.2.0-master-SNAPSHOT"] [org.clojure/clojure-contrib "1.2.0-SNAPSHOT"] [org.clojars.k

Re: Reorder a list randomly?

2010-04-05 Thread Linus Ericsson
I'm overwhelmed by the answers, thank you all! Now back to the REPL. /Linus 2010/4/5 Per Vognsen > On Mon, Apr 5, 2010 at 11:33 AM, Lee Spector > wrote: > > > > Ah -- maybe that foiled my timings too. I didn't expect it to be fast -- > just clear (at least to this Lisp programmer). > > Embrace

Reorder a list randomly?

2010-04-04 Thread Linus Ericsson
Hello Clojure! Is there any straight-forward way to randomly reorder a list? ie: (randomize-list (list 1 2 3 4)) -> (3 2 1 4) Regards, Linus Ericsson -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send ema