Re: Large lazy seq = StackOverflow?
On Oct 21, 9:14 pm, John Harrop wrote: > You probably therefore want this instead: > > (defn multi-filter [filters coll] > (let [c (count filters) > ignore (Object.)] > (map > (fn [i] > (remove #(= % ignore) > (take-nth c > (drop i > (mapcat #(map (fn [p e] (if (p e) e ignore)) filters (repeat c > %)) coll) > (range c Good idea, thanks! I had to modify it because it was generating a separate "merged-seq" per filter: (defn multi-filter [filters coll] (let [c (count filters) ignore (Object.) merged-seq (mapcat (fn [k] (map (fn [p e] (if (p e) e ignore)) filters (repeat c k))) coll)] (map (fn [i] (remove #(= % ignore) (take-nth c (drop i merged-seq (range c Very cool (and lazy)! - Dmitry --~--~-~--~~~---~--~~ 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: Converting symbols to strings
Thanks for the help! I created a small function, which convert the nodes of a nested collection to strings: (defn rec-to-strs [f] "recursively change parameters to strings" (vec (for [c f] (if (coll? c) (vec (rec-to-strs c)) (str c) I use this function from a macro as suggested. On Oct 22, 4:53 pm, Sean Devlin wrote: > Or, you could just write foo as > > ;;Adjusting for 2d > (defmacro foo > [vec-vec-of-symbols] > (let [vec-vec-of-str (vec (map (comp vec (partial map str)) vec-vec- > of-symbols))] > `(foo* ~vec-vec-of-str))) > > This let you write foo* to handle strings. Anyway, the key thing to > note in both examples is that the heavy lifting is delegated to > another function. This is an element of good macro design. > > Just my $.02 > > On Oct 22, 10:29 am, Meikel Brandmeyer wrote: > > > Hi, > > > On Oct 22, 4:22 pm, Tzach wrote: > > > > I’m writing a small facility which get vector of vectors of names > > > (strings) and print them in a special format. > > > Something like (foo [[“aname” “a-different-name”] [ “oneMoreName”]]) > > > This works fine, but make it hard to write all the quotations when > > > many parameters are used. > > > > What is the simplest way to define foo as > > > (foo [[aname a-different-name ] [oneMoreName]]) ? > > > > Is macro required? (I guess it is) > > > It is, but a simple one. Rename your foo function to foo* and create a > > simple macro called foo like that: > > > (defmacro foo > > [vec-of-symbols] > > `(foo* (quote ~vec-of-symbols))) > > > There you go. (Of course you must now handle Symbols in your foo* star > > function instead of Strings...) > > > 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 -~--~~~~--~~--~--~---
Re: Scientific computing
On 23 Oct 2009, at 22:00, Konrad Hinsen wrote: > For matrix computations and linear algebra, your best choice is > probably > the Colt library developed at CERN, or the somewhat parallelized > version called Parallel Colt. Colt has arrays up to three dimensions > for > a couple of data types, enough for matrix stuff but not much more. > > If you need higher-dimensional arrays, e.g. to store complex data > sets, > your best bet would be the netCDF implementation for Java, which > contains a very complete array library that handles any number of > dimensions. However, it provides no linear algebra at all. I should have added that it is possible to convert between netCDF and Colt arrays without a costly element-by-element copying procedure. For example, the following code inverts a matrix read from a netCDF file using Colt: (ns netcdf-read (:import (ucar.nc2 NetcdfFile) (cern.colt.matrix.tdouble.impl DenseDoubleMatrix2D) (cern.colt.matrix.tdouble.algo DenseDoubleAlgebra))) (defn unidata-to-colt [#^ucar.ma2.ArrayDouble$D2 array] (let [java-array-1d (.get1DJavaArray array Double) [rows, cols] (.getShape array)] (new DenseDoubleMatrix2D rows cols java-array-1d 0 0 cols 1 false))) (let [matrix (with-open [ncfile (NetcdfFile/open "/Users/hinsen/ Temp/matrix.nc")] (.read (.findVariable ncfile "matrix"))) colt-matrix (unidata-to-colt matrix) la (new DenseDoubleAlgebra) inverse (.inverse la colt-matrix)] (prn inverse)) Konrad. --~--~-~--~~~---~--~~ 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 in a big Java solution
It's difficult to provide advice without more information about your current code. You say that you want a part of your system, which manipulates a lot of objects, to run in parallel. Do you mean that you want this part of the system to run parallel to the other parts -or- do you mean that this part will remain in sequence with the other parts of the system, but it will run its own tasks in parallel? Furthermore, what do you expect to gain from the parallelism? If it's simple divide-and-conquer parallelism to process a chunk of data faster, then that is pretty easy to implement in Java, so long as the data is dividable. On the other hand, if you want this part of your system to run in parallel with the other parts, then there's a wide spectrum of Clojure/Java mixes that could make sense. Like I said above, we'll need much more information before we can provide any valuable advice. On Oct 23, 7:41 am, vanallan wrote: > Hi! > I am currently investigating if it is possible to convert a part of a > big Java system to Clojure. The reason for this is to make this part > run in parallel and hence ease the implementation by porting it to > Clojure. The problem is that these parts of the system is today > setting and changing a lot mutable data in a lot of different objects. > > Which approach do you think i should have when i try to port these > Java methods? Should i try to retain the Java structure and change > these objects or is it better to create my own data structure and > somehow manage them? Does anyone have any experience in integrating > Clojure in a big Java solution? Also i should mention that i'm quite > new to Clojure, and functional programming overall. :) > > 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 -~--~~~~--~~--~--~---
STM talk
I gave a talk on STM at a conference in St. Louis called "Strange Loop" last Thursday. 1 up and 2 up PDF versions of the slides are available at http://ociweb.com/mark/stm/. The talk was videotaped. I'll send another email when that is available. Feedback is welcomed! I'll update the slides if needed. -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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: Macro newbie: Trying to create a map template
Thanks a lot! I didn't know about the existence of gensym. This will help a lot. On Oct 23, 9:54 pm, John Harrop wrote: > On Sat, Oct 24, 2009 at 12:19 AM, samppi wrote: > > user=> (defmacro b [form] > > (let [processed-form (a form rec#)] > > `(fn [rec#] processed-form))) > > java.lang.Exception: Unable to resolve symbol: rec# in this context > > (NO_SOURCE_FILE:39) > > Try > > (defmacro b [form] > (let [r (gensym) > processed-form (a form r)] > `(fn [~r] ~processed-form))) > > You need to replace rec# with a *reference* to a symbol. If you use a > literal symbol (including a literal gensym) it will try to take its value > even though you haven't assigned it yet. When you called a manually you > passed it a quoted symbol, so a symbol rather than the result of > dereferencing one. To get a symbol as the second argument to a in the macro > you need a pointer TO a gensym, which the first binding in my version of the > let gets you, in r. > > You also need to unquote the expressions that should be filled in from the > let bindings. Otherwise you'd get (fn [r] processed-form) instead of (fn > [G_1746] (:a G_1746)) or whatever you actually want. --~--~-~--~~~---~--~~ 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: Macro newbie: Trying to create a map template
On Sat, Oct 24, 2009 at 2:43 PM, samppi wrote: > Thanks a lot! I didn't know about the existence of gensym. This will > help a lot. You're welcome. --~--~-~--~~~---~--~~ 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: Why can't :let be first in a for
>From my perspective, having the forms be flatter (less nested) and having the call to the extend-dom function be at the outermost level is the most readable. On Fri, Oct 23, 2009 at 1:20 PM, Meikel Brandmeyer wrote: > Hi, > > Am 23.10.2009 um 21:16 schrieb Howard Lewis Ship: > >> Here's what I wanted to write: >> >> (defn add-script-links-for-imported-javascript-libraries >> [env dom-nodes] >> (extend-dom dom-nodes [:html :head] :top >> (template-for [:let [aggregation (-> env :cascade :resource- >> aggregation) >> libraries (@aggregation :libraries)] >> asset-map libraries >> :let [path (to-asset-path env asset-map)]] >> :script { :type "text/javascript" :src path } [ >> linebreak ]))) > > Why don't you just go one step further? > > (defn add-script-links-for-imported-javascript-libraries > [env dom-nodes] > (extend-dom dom-nodes [:html :head] :top > (template-for [asset-map (-> env > :cascade > :resource-aggregation > deref > :libraries) > :let [path (to-asset-path env asset-map)]] > :script { :type "text/javascript" :src path } [ linebreak ]))) > >> But I had to juggle it to this: >> >> (defn add-script-links-for-imported-javascript-libraries >> [env dom-nodes] >> (let [aggregation (-> env :cascade :resource-aggregation) >> libraries (@aggregation :libraries)] >> (extend-dom dom-nodes [:html :head] :top >> (template-for [asset-map libraries >> :let [path (to-asset-path env >> asset-map)]] >> :script { :type "text/javascript" :src path } >> [ linebreak ] >> >> >> Of course there are any number of ways to write this, but I prefer the >> first option, as it does less of a job of obscuring what the main >> point of the function is: a call to extend-dom. > > I don't see any obfuscation. Especially if you add a docstring "Extend > DOM with ..." to the function. > > Sincerely > Meikel > > -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.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 -~--~~~~--~~--~--~---
Re: is there a cannonical way to create executable jar files?
for anyone who has this same problem. The only solution that I've gotten so far that works is to use a java file that launches my clojure files. I'm still looking for a better way to do this. Here is the code for the launcher. import java.io.OutputStreamWriter; import java.io.IOException; import clojure.lang.RT; import clojure.lang.Compiler; import clojure.lang.Var; public class Launcher { public static void main(String[] args) throws Exception { // Load the Clojure script -- as a side effect this initializes the runtime. RT.loadResourceScript("main/ironlily.clj"); // Get a reference to the -main function, which is in the namespace ironlily. Var main = RT.var("ironlily", "-main"); // Call it! Object result = main.invoke(); } } --~--~-~--~~~---~--~~ 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: is there a cannonical way to create executable jar files?
> for anyone who has this same problem. The only solution that I've > gotten so far that works is to use a java file that launches my > clojure files. I'm still looking for a better way to do this. I've had success on several projects with: (ns com.foo.bar (:refer-clojure) (:gen-class)) ; I haven't even tried adding :main true. (defn -main [& args] ...) with the appropriate Ant chunk to build the manifest: This allows you to do java -jar my-jar which, on my Mac at least, means it'll run when you double-click it. The difference here is that I'm AOT-compiling everything, but you're not. Is that correct? If you're trying to bundle your .clj files into the JAR, you might have trouble — you'll need somehow to get Clojure's classloader to look for your main class, because the Java classloader won't look for .clj files, and wouldn't know what to do with them anyway. gen- class only works if you AOT-compile. I can't see any reason why you wouldn't AOT-compile when you're building a jar. --~--~-~--~~~---~--~~ 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: Writing binary data using http.agent and duck-streams
Baishampayan Ghose writes: > Hello, > > I was trying to download a zip file using clojure.contrib.http.agent and > writing it to a file using clojure.contrib.duck-streams. > > Apparently the zip file is getting corrupt because I was trying to treat > the stream as a string. > > Is there any way to use duck-streams to write data as binary? > > I looked at the code but I am not sure about the exact way to do it. I > can probably use straight Java interop, but I would rather use the > contrib lib. "reader" and "writer" from duck streams are intended only for character streams and AFAIK there are no binary counterparts available so far. So the only way is to use Java streams directly. This is what I came up with: (ns test-http (:require [clojure.contrib.duck-streams :as ds] [clojure.contrib.http.agent :as http]) (:import [java.io FileOutputStream])) (await (http/http-agent "http://clojure.googlecode.com/files/clojure_1.0.0.zip"; :handler (fn [agnt] (with-open [w (FileOutputStream. "clojure.zip")] (ds/copy (http/stream agnt) w) (shutdown-agents) HTH, Rob --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Code improvement: searching a tree
I suspect the code below can be improved. The function returns the set of all symbols inside a list-tree that are not at the beginning of a list. Is there a way to make the code more compact or faster? (with-test (defn- find-dependencies [rel-rep] (cond (list? rel-rep) (let [[_ & tail] rel-rep] (into #{} (mapcat find-dependencies tail))) (symbol? rel-rep) #{rel-rep} :default nil)) (is (= '#{a b c} (find-dependencies '(+ b (- c 3 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 -~--~~~~--~~--~--~---
Re: Code improvement: searching a tree
This is a slightly faster and somewhat shorter version: (defn find-dependencies2 [rel-rep] (set (filter symbol? (tree-seq seq? rest rel-rep - James On Oct 24, 9:55 pm, samppi wrote: > I suspect the code below can be improved. The function returns the set > of all symbols inside a list-tree that are not at the beginning of a > list. Is there a way to make the code more compact or faster? > > (with-test > (defn- find-dependencies > [rel-rep] > (cond > (list? rel-rep) > (let [[_ & tail] rel-rep] > (into #{} (mapcat find-dependencies tail))) > (symbol? rel-rep) > #{rel-rep} > :default > nil)) > (is (= '#{a b c} > (find-dependencies > '(+ b (- c 3 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 -~--~~~~--~~--~--~---
Re: Code improvement: searching a tree
Jeez, that's amazing. Thanks a lot; I had no idea that trees-seq existed. I keep getting surprised by Clojure. On Oct 24, 2:05 pm, James Reeves wrote: > This is a slightly faster and somewhat shorter version: > > (defn find-dependencies2 > [rel-rep] > (set (filter symbol? (tree-seq seq? rest rel-rep > > - James > > On Oct 24, 9:55 pm, samppi wrote: > > > > > I suspect the code below can be improved. The function returns the set > > of all symbols inside a list-tree that are not at the beginning of a > > list. Is there a way to make the code more compact or faster? > > > (with-test > > (defn- find-dependencies > > [rel-rep] > > (cond > > (list? rel-rep) > > (let [[_ & tail] rel-rep] > > (into #{} (mapcat find-dependencies tail))) > > (symbol? rel-rep) > > #{rel-rep} > > :default > > nil)) > > (is (= '#{a b c} > > (find-dependencies > > '(+ b (- c 3 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 -~--~~~~--~~--~--~---
Re: STM talk
After reading your PDF, I now understand what Clojure means by the term "coordinate". Thanks a lot! -- coordinating activities of multiple actors (i.e. transactions) • may want to send messages to multiple actors within a txn and guarantee that either all messages are processed successfully or all the actors involved rollback changes to their retained state -- On Oct 25, 2:35 am, Mark Volkmann wrote: > I gave a talk on STM at a conference in St. Louis called "Strange > Loop" last Thursday. > 1 up and 2 up PDF versions of the slides are available > athttp://ociweb.com/mark/stm/. > The talk was videotaped. I'll send another email when that is available. > Feedback is welcomed! I'll update the slides if needed. > > -- > R. Mark Volkmann > Object Computing, Inc. --~--~-~--~~~---~--~~ 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: Scientific computing
Thanks for your replies. You've been very helpful. On Oct 24, 1:36 pm, Konrad Hinsen wrote: > On 23 Oct 2009, at 22:00, Konrad Hinsen wrote: > > > For matrix computations and linear algebra, your best choice is > > probably > > the Colt library developed at CERN, or the somewhat parallelized > > version called Parallel Colt. Colt has arrays up to three dimensions > > for > > a couple of data types, enough for matrix stuff but not much more. > > > If you need higher-dimensional arrays, e.g. to store complex data > > sets, > > your best bet would be the netCDF implementation for Java, which > > contains a very complete array library that handles any number of > > dimensions. However, it provides no linear algebra at all. > > I should have added that it is possible to convert between netCDF and > Colt arrays without a costly element-by-element copying procedure. For > example, the following code inverts a matrix read from a netCDF file > using Colt: > > (ns netcdf-read > (:import (ucar.nc2 NetcdfFile) > (cern.colt.matrix.tdouble.impl DenseDoubleMatrix2D) > (cern.colt.matrix.tdouble.algo DenseDoubleAlgebra))) > > (defn unidata-to-colt > [#^ucar.ma2.ArrayDouble$D2 array] > (let [java-array-1d (.get1DJavaArray array Double) > [rows, cols] (.getShape array)] > (new DenseDoubleMatrix2D rows cols java-array-1d 0 0 cols 1 false))) > > (let [matrix (with-open [ncfile (NetcdfFile/open "/Users/hinsen/ > Temp/matrix.nc")] > (.read (.findVariable ncfile "matrix"))) > colt-matrix (unidata-to-colt matrix) > la (new DenseDoubleAlgebra) > inverse (.inverse la colt-matrix)] > (prn inverse)) > > Konrad. --~--~-~--~~~---~--~~ 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: is there a cannonical way to create executable jar files?
On Sat, Oct 24, 2009 at 10:50 PM, Richard Newman wrote: > >> for anyone who has this same problem. The only solution that I've >> gotten so far that works is to use a java file that launches my >> clojure files. I'm still looking for a better way to do this. > > I've had success on several projects with: > > (ns com.foo.bar > (:refer-clojure) > (:gen-class)) ; I haven't even tried adding :main true. > > (defn -main [& args] > ...) > > > with the appropriate Ant chunk to build the manifest: > > > > > > > > > > > > > > > > > > > This allows you to do > > java -jar my-jar > > which, on my Mac at least, means it'll run when you double-click it. > > The difference here is that I'm AOT-compiling everything, but you're > not. Is that correct? > > If you're trying to bundle your .clj files into the JAR, you might > have trouble — you'll need somehow to get Clojure's classloader to > look for your main class, because the Java classloader won't look > for .clj files, and wouldn't know what to do with them anyway. gen- > class only works if you AOT-compile. > > I can't see any reason why you wouldn't AOT-compile when you're > building a jar. > > > I have a clojure project stub at, http://github.com/nakkaya/clojure-stub That will let you build a executable jar. running ant deps will download the clojure.jar and clojure-contrib.jar running ant setup will create the required sources to create a hello world application. running ant compile will create single executable jar that you can distribute. You can use it as a starting point for your application. -- Nurullah Akkaya http://nakkaya.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 -~--~~~~--~~--~--~---
Re: STM talk
I'm confused about the slide on barging: "txnB has a status of RUNNING and can be changed to KILLED". Are you implying that simply having a status of RUNNING is all that is required for the txn to be killed? Or, are there other requirements to "can be changed"? I'm having a hard time wrapping my head around the idea of the STM just killing a fn. Unless... the fn will be retried later. I couldn't find a good description of what 'killing a fn' means. Thanks for sharing the slides. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
SICP in Clojure
Hadn't seen it posted here yet: http://sicpinclojure.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 -~--~~~~--~~--~--~---
reading a range from a large file
I have a huge file(>900MB) that I would like to read/process in chunks. In clojure, i can grab the first n lines nicely: (with-open [r (reader "FILE")] (str-join ", " (take n (line-seq r How can i grab the first n lines starting from an line offset? ex, grab lines 5 to 10 rather than just the first 5. I can do this in java using traditional java way by using LineNumberReader's setLineNumber(int lineNumber) but i'm not sure how to interweave this in with clojure's file sequence operations. --~--~-~--~~~---~--~~ 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: reading a range from a large file
> In clojure, i can grab the first n lines nicely: > (with-open [r (reader "FILE")] (str-join ", " (take n (line-seq r > > How can i grab the first n lines starting from an line offset? ex, > grab lines 5 to 10 rather than just the first 5. (with-open [r (reader "FILE")] (str-join ", " (take 5 (drop 5 (line-seq r) This still does the work of finding all the \ns that you skip, of course. Linewise navigation of a file is not as fast as seeking to byte offsets. > I can do this in java using traditional java way by using > LineNumberReader's setLineNumber(int lineNumber) but i'm not sure how > to interweave this in with clojure's file sequence operations. (with-open [#^Reader r (reader "FILE")] (with-open [lr (java.io.LineNumberReader. r)] (.setLineNumber lr 5) ;; Your code here. ))) --~--~-~--~~~---~--~~ 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: SICP in Clojure
On Sat, Oct 24, 2009 at 10:19 PM, Robert Stehwien wrote: > Hadn't seen it posted here yet: > http://sicpinclojure.com/ > Are they looking for help writing Clojure versions of the Scheme code snippets? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
News on Mini Kanren / Javascript generator; when is an implementation sufficiently original?
Jim was working on logic programming in Clojure up to a few months ago, and it seems as if the concern was that the code was too derivative. I have recently made available a Scala-based Kanren implementation; the differences between Scala and Scheme means that the code is sufficiently original. Most of the code was written based on the descriptions of how Mini Kanren works, and not the Scheme implementation. And I have signed the Clojure contributor CA. Would a clean-room implementation based on the Scala code be considered sufficiently owned for inclusion in contrib? Am I considered "tainted" enough because I have, for comparison purposes, seen the Scheme Kanren code -- in which case a third-party can reimplement the Clojure port -- or can I do it myself? Thanks, -- Michel --~--~-~--~~~---~--~~ 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: Scientific computing
> If all you need is a statistical or array-processing language like MATLAB, > my frank view is you're best off staying in R, or Mathematica, or MATLAB, or > Octave, or whatever... they're mature and great at what they do (Mathematica > most of all ;-) ). The reason you might want to use Clojuratica or Incanter > is if you're building applications that need Clojure's awesome features in, > say, concurrency, *plus* array processing. Lisp/Clojure offers such a compelling advantage for software design of complex applied math algorithms over some of the systems you have named that I think it bowls over some long-suffering Matlab/R/Python users, who are inspired work in Clojure in spite of incomplete (but still surprisingly good) support for their specialized needs. Hopefully Clojure's flexibility will soon allow it to become a matrix- oriented language as well, if only to express linear-algebra-type ideas (which are stored under the hood in whatever format or system needed---Colt, CDF, Mathematica arrays even!). I wanted to let you know that probably for every person who asks about Clojure scientific computing, there's a number of others who are just trying to make it work for them! (By the way, Garth, great work on Clojuratica!) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---