Re: Porting Clojure to Native Platforms
My 2¢ on the subject, Ferret is not dead, I've been working on it for sometime now. Latest builds/docs are available at [1]. > Can the Immutable Persistent Data Structures be implemented with a reference-counting scheme rather than a garbage collector? This may improve performance. That is what Ferret uses. But reference-counting is not cheap. This snippet, (reduce + 0 (range 1)) will spend most of its time inc/dec reference counts (When running in single threaded mode with a memory pool.). > In a similar vein, can the allocation strategy be controlled for these structures in such a way as to optimize cache locality? Currently when running on embedded systems or in single threaded mode ferret can be configured to run using a memory pool. This avoids calling malloc/heap at runtime, improves performance and determinism you can also tell how much memory will be used at compile time. In single threaded mode this also improves cache locality. (A linked list is just a sequential memory blocks from the pool allocated on the stack.) > It wouldn't have to depend on an existing runtime environment like JVM or JavaScript. Ferret uses its own runtime. No third party dependencies. Generated code is strict ISO C++11. > Could certain anonymous functions be optimized or inlined in a way that improves performance over JVM/JS implementations? Ferret does simple escape analysis when you are not passing a fn as variable, it is created on the stack. A ferret function is a C++ functor and no runtime lookup is necessary, compiler should be able to inline them depending on the optimization level. > Is there a way to compile C++ code at runtime? This would be essential for the REPL and for Macros. This is not necessary for macros. Ferret is intended for embedded systems a REPL is not really useful when you have to jump through hoops to communicate with the device. Ferret does supports macros. Everything is compiled there is no reader or eval, you can't add/remove/resolve symbols during runtime. (Unless you setup your own system for it.) > The main motivation would be performance gains. Speed is not my main motivation. Ferret is not lighting quick but allows you to easily interact with C,C++ libraries or drop in arbitrary C++ code to squeeze that last bit of performance for critical sections of code. i.e As someone already said in the thread with ferret you can take the julia route. > Julia relies on external native libraries for performance (BLAS, GPU, whatever). The speed of those libraries is not due to the language (usually C or ASM) but to the fact that they use algorithms that are heavily optimized for each hardware architecture [1] http://dropbox.nakkaya.com/builds/ferret-manual.html Best, On Mon, Apr 25, 2016 at 10:47 PM, JvJ <kfjwhee...@gmail.com> wrote: > I've been wondering lately about getting Clojure to compile to native > code, and so I've been doing some looking around. > > There are a few projects that are on the right track, such as TinyClojure > <https://github.com/WillDetlor/TinyClojure> and Ferret > <http://nakkaya.com/2011/06/29/ferret-an-experimental-clojure-compiler/>, > but they are incomplete and don't seem to be under active development any > more. > > I'm wondering about the requirements, how much work it would take, and > whether or not it would be worth it. My current thinking is of a > Clojure->C/C++ compiler. > > So far, I have a few topics for discussion that I'm unclear about that > might be necessary for this kind of project: > >- Can the Immutable Persistent Data Structures be implemented with a >reference-counting scheme rather than a garbage collector? This may >improve performance. >- In a similar vein, can the allocation strategy be controlled for >these structures in such a way as to optimize cache locality? >- Can we take advantage of tail-call optimization in existing C++ >compilers? >- It wouldn't have to depend on an existing runtime environment like >JVM or JavaScript. > - Could this reduce reliance on reflection and increase performance? > - Could a new, clojure-optimized runtime be created that improves > performance? >- Could certain anonymous functions be optimized or inlined in a way >that improves performance over JVM/JS implementations? >- Is there a way to compile C++ code at runtime? This would be > essential for the REPL and for Macros. > > > Let me know if anyone has any thoughts on the matter. > > Thanks > -- 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 fr
Re: Clojure On Java Friendly Microcontrollers, Beaglebone, etc
I have not played with Java friendly micros but Clojure works on the beagle/pi. As for building robots using clojure, - Our software for our Robocup team is all Clojure except couple hundred lines of C for the firmware running on the AVRs. All heavy lifting is done on the PC, AVRs only deal with interfacing with the motor controllers, kicking circuit etc. [5] is our old code from 2012. - I was working on a blob tracking nerf gun which I never finished. That was using beagleboard for vision and an Arduino for controlling the servos. I never finished it and I did port it to gambit scheme for some reason I don't remember. It used, vision[1] to find/track blobs and cloudino[2] to talk to Arduino which controlled the servos of the gun. When using beagle/pi you are going to need a seperate microcontroller to deal with real time stuff, PWM generation etc. Another option I am playing with right now is actually putting an android phone on the robot. - I did port a simple autopilot (following a set of waypoints using, GPS from the phone and IMU from the AR Drone) to android using lein droid [3]. Taped the phone on top of an Ar Drone. It barely worked in the lab with mock GPS when there was no wind but the phone is too heavy for AR Drone but this scheme would work with a more power full quad. - I am applying the same idea to a boat now. Android phone on the boat, a webapp (http-kit/compojure/hiccup) for getting telemetry and setting way points over 3G, usb-serial-for-android[4] for talking to arduino which handles interfacing with the motor controllers, phone GPS/IMU for navigation. [1] https://github.com/nakkaya/vision [2] https://github.com/nakkaya/clodiuno [3] https://github.com/clojure-android/lein-droid [4] http://code.google.com/p/usb-serial-for-android/ [5] http://dropbox.nakkaya.com/neu-islanders.pdf Best, On Mon, Sep 2, 2013 at 6:21 AM, Jeremy Wright wright...@gmail.com wrote: Here are some updates on my own research. This post is a little over a year old, but has the type of information on the BeagleBone I'm looking for. It covers doing some simple I/O using Clojure. The author states that he's unsure what he's doing on the hardware side of things, but it's a start. This post says it's easy to get Clojure working on the Beagleboard, but is a couple of years old and doesn't give too much detail. I do like that the author does some benchmarking that could be adapted to the BeagleBone Black though. This post is about a year old, and gives a benchmark comparison of OpenJDK vs Oracle's Embedded JRE on a BeagleBone. Videos of Kevin Downey (less than a year old) showing a robot using Clojure on a BeagleBone. He gives some insight into how to make using the Bone's I/O system in Clojure a little easier. Video 1 of 3 Video 2 of 3 Video 3 of 3 Kevin Downey's Beaglebone robot code on Github. Kevin Downey mentioned clojure-jna which should make working with native code (to do I/O) on the Bone a little easier. The clojure-jna code on GitHub is about 4 years old though, and I may have read something about a newer replacement on this mailing list. I can't remember for sure though. That's what I've found so far. The information has some age on it and is focused on the older BeagleBone and Beagleboard. It's good information to get started with though I think. On Saturday, August 31, 2013 11:13:59 PM UTC-4, Jeremy Wright wrote: I recently watched Carin Meier's OSCON talk The Joy of Flying Robots with Clojure and it made me wonder about Clojure on embedded systems. A quick search on this list didn't turn up much so I thought I'd ask. How much work has been done with Clojure on either Java friendly microcontroller systems (i.e. Systronix), or on something like a Beaglebone or Beagleboard? I'm very new to Clojure, so I don't yet understand the challenges that Clojure would face trying to run on a system that may not support all the JVM's features. Any thoughts on this? Any links you can give me on what's been/being done? 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 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. -- 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
Re: [ANN] Clojars Releases repository
Is there a particular reason for not using Bouncy Castle[1]. Instead of forcing users to install gpg lein can generate and/or upload the key. [1] http://www.bouncycastle.org/ -- Nurullah Akkaya http://nakkaya.com On Mon, Nov 19, 2012 at 10:08 PM, Lee Hinman matthew.hin...@gmail.comwrote: Jeff Heon writes: As a starting point, the gpg website features native installers for both Windows and Mac OS. http://www.gnupg.org And for OSX: https://www.gpgtools.org/ ; Lee -- 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: Transforming map entries
You can use map to get your new sequence of pairs, the turn it into a hash-map using into, (- {:first john :last smith :age 25} (map #(let [[k v] %] (if (string? v) [k (.toUpperCase v)] [k v]))) (into {})) Best, -- Nurullah Akkaya http://nakkaya.com On Tuesday, February 22, 2011 at 5:08 AM, yair wrote: I'm hoping this is a dumb question and I've missed something obvious. I have a map with various key-value pairs and I want to transform some of the values, e.g. (def mymap {:first john :last smith :age 25}) and say I want to change the strings to be upper case. Right now all I can think of doing is using reduce and passing in an empty map and the re-associating each key with the (possibly) transformed value. Is there something like the map function that takes two parameters, one a function that receives a pair and returns a new pair, and the other a map, and returns a map that's reconstituted from those pairs? 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: api doc for clojure/libraries
No need for wget etc, For core you can download from, https://github.com/clojure/clojure/tree/gh-pages For contrib, https://github.com/clojure/clojure-contrib/tree/gh-pages Just click on download... Regards... -- Nurullah Akkaya http://nakkaya.com On Mon, Jan 24, 2011 at 5:55 PM, Ken Wesson kwess...@gmail.com wrote: you could always use wget, or even java.net.HttpURLConnection at a REPL, -- 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: distributeted computing newby, clojure ...
Hi Nick, You can reach me from this email. If you have a patch, you can send a pull request or email it directly. Regards... -- Nurullah Akkaya http://nakkaya.com On Wed, Jan 12, 2011 at 1:13 AM, Nick Zbinden nick...@gmail.com wrote: I have a simple library that mimics newLISP's net-eval command, which will allow you to evaluate expressions in parallel on remote network nodes, http://nakkaya.com/net-eval.html Regards... Very Nice. I looked at it and its what I need. I tested it sucessfully and I am using it with in my project atm. Will you keep developing this? I will probebly work on it, do you accept patches? (Maybe we can keep talking about this on direct email.) -- 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: distributeted computing newby, clojure ...
I have a simple library that mimics newLISP's net-eval command, which will allow you to evaluate expressions in parallel on remote network nodes, http://nakkaya.com/net-eval.html Regards... -- Nurullah Akkaya http://nakkaya.com On Sat, Jan 8, 2011 at 4:12 AM, Nick Zbinden nick...@gmail.com wrote: Hallo, I would like to talk about two things. General: I have a small project that has really easy to paralyzable problem so I think that a good place to start with parallel programming. Doning it on one pc is simple in clojure. So I tought to myself: You can distribute that. I have never done anything like that bevor (not in clojure or any other language). So I wanted to ask people. Have you done distributed stuff in clojure? Whats the easiest way distribute? Are there librarys to help or should I start reading into Java Distributet librarys? My Project: I think I quickly explain my project. Think you have pool of something (for example diffrent fighters for a game). I want to find out witch one is the best. So I want to write a function that takes some fighters and a function to compair two of the fighters and a function that decides how to play it out (K.O.-Mode, All-Vs-All, Playoff Style). To make this multithread my take on this would be to generat a future for every fight and then just do you match and deref if you need a winner. (is this a good idea?) (Warning the stuff I take about now is just guessing correct me if I talk total nosence) To distribut this I would have to need something like an Pool of Workers or some kind of executer that handles that stuff. My thinking was I could provid the executer as an I argument (the futures would just be send in to the executer the executer then decides to run it with normal threads or do distributed work. This would be a general library to find out the best of anything. In my example fighter with diffrent attribut configurations. Love to hear your thoughts. -- 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: Creating a new library
For each non-clojure jar file you have, you need to create a pom.xml file using the instructions here, http://github.com/ato/clojars-web/wiki/POM and scp the pom file and the jar to clojars, then you can include them in your project.clj. So if Minim.jar depends on A.jar, B.jar, upload A.jar and B.jar and make Minim.jar depend on A and B then when you add Minim as your dependency in project.clj it will pull A, B and Minim. Regards... -- Nurullah Akkaya http://nakkaya.com On Wed, Oct 13, 2010 at 12:52 AM, Vilson Vieira vil...@void.cc wrote: Hello, I want to create a Clojure wrapper for Minim and push to clojars. So I have a bunch of jar files from Minim as deps and I want to put them on my lib/. How can I add a non-clojure jar file on my lein project? Or I need to create a specific lein project for every jar? Like there's a processing.core for Processing jar [1]. Thanks. PS: who is the user fyuryu from clojars? I think he could help me. [1] http://clojars.org/org.clojars.fyuryu/processing.core -- Vilson Vieira vil...@void.cc ((( http://automata.cc ))) ((( http://musa.cc ))) -- 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: Clojure Serial Connection
Hi Ivan, I have a project called Clodiuno which allows you to control an Arduino board using either serial or TCP/IP protocol, that may give you a head start, http://github.com/nakkaya/clodiuno/blob/master/src/clodiuno/firmata.clj http://nakkaya.com/clodiuno.html Regards... -- Nurullah Akkaya http://nakkaya.com On Tue, Sep 21, 2010 at 6:17 AM, Ivan Willig iwil...@gmail.com wrote: I list, i am trying to connect to a USB GSM Modem with clojure. Basically, i want to open a serial connection to my modem and be able to pass commands to it. ( I think I am new to this whole modem thing). I know I can do this in Java, but wanted to check if someone had a working solutions in Clojure. I am looking similar to this http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/14d33b36279fe104/b7d0caa5540b0281?#b7d0caa5540b0281 I have google around and not really found anything. Does anyone have any suggestions? Thanks Ivan Willig -- 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 gui is flashing
On Sun, Jul 25, 2010 at 12:55 PM, Ryan Twitchell metatheo...@gmail.com wrote: You'd be best served overriding the JPanel's paint or paintComponent method (I'm fuzzy on the difference), and then calling repaint periodically (at your desired frame rate). IIRC, repaint is safe to call from any thread, and it will cause the paint methods to be called in the swing thread. Also, try to ensure your swing setup code runs in the swing thread if possible (see Brian's reply). Unless you have a good reason, you should not override paint, http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/painting/closer.html -- 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: java gui is flashing
It is probably happening because a bare bones JPanel is a white canvas every time swing paints it, it paints a white canvas than your routines paint over that giving you the flashing behavior, right way to paint on a JPanel is to extend it using proxy and overwrite paintComponent method, this is the method Java calls when it wants to paint a component. However it won't call it all the time, it will be called only when swing thinks component needs a repaint (i.e when you resize the frame). In order to create animations on the panel you have two choices, you can use a swing timer and call repaint on the panel say ever 100 ms or if your state is held in a ref you can add a watch to the ref that will call repaint whenever ref is updated. You can copy/paste the last snippet from, http://nakkaya.com/2010/07/21/physics-with-clojure/ which uses the former method for painting on a JPanel. Hope this helps... -- Nurullah Akkaya http://nakkaya.com On Sat, Jul 24, 2010 at 4:11 PM, Mate Toth totm...@gmail.com wrote: Hi, my problem is that during execution my presentation java applet is flashing. There are many components which paint to a JPanel using it's Graphics (.getGraphics). I think maybe the problem is that I don't have any paint everything now routine..(I don't know which Java routine to use, how I have to synchronize it etc..) Thanks for your time and help. I've the following code for the gui part (fe stands for flocking- enviroment, I'm making a flocking library): The main loop: (defn main [starting-fe] (let [first-fe starting-fe panel (new JPanel) frame (new JFrame)] ;; configuring panel (. panel setPreferredSize (new Dimension width height)) ;; configuring frame (. frame add panel) (. frame pack) (. frame setVisible true) (loop [fe first-fe] (draw-fe fe panel) (Thread/sleep 100) (recur ((:update-f fe) fe) Blanking the screen: (defn blank-panel [panel] (let [g (. panel getGraphics)] (. g setColor (. Color BLACK)) (. g fillRect 0 0 width height At the end every boid drawed by this(called by the draw-fe function): (defn draw-boid [boid panel] (let [[x0 x1] (:pos boid)] (let [g (. panel getGraphics)] (. g setColor (:color boid)) (. g fillRect (- x0 2) (- x1 2) 5 5) -- 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: Make a loop in a loop
You can build a sequence of year week pairs using, (for [y (range 1999 2011) w (range 1 53)] [y w]) then you can iterate over that and print, (doseq [[y w] (for [y (range 1999 2011) w (range 1 53)] [y w])] (println Year y Week w)) Hope it helps... -- Nurullah Akkaya http://nakkaya.com On Wed, Jul 7, 2010 at 5:47 PM, uap12 anders.u.pers...@gmail.com wrote: Hi! I try to make a printout witch vill have year 1999-2010 and every week Eg. Year=1999 Week=1 Year=1999 Week=2 Year=1999 Week=3 Year=1999 Week=4 Year=2000 Week=1 I have made the program in java, but like to try making it in Clojure, but so far i have got (defn print-data [year week] (println (str Y= year W= week))) // This would not work and i can't find how to map (print-data with a external variabel and a range // I can set week to a fixed number but not. // Or is this the wrong way of doing it ?? (defn print-data2 [year] (map (print-data year *) (range 1 53 1))) (defn run [] (map print-data2 (range 1999 2010 1) ) ) The program vill call an externa system program, with year and week as input, but for this test i just like to write them... // Anders -- 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: Newb Question
Hi José, user= (apply str (repeat 3 code)) codecodecode will give you what you want, if we break it down, user= (repeat 3 code) (code code code) repeat will give you a sequence of xs, since you don't know the length of the sequence at compile time we apply str to the sequence (apply str '(code code code)) which basically expands to, (str code code code) then you get, codecodecode -- Nurullah Akkaya http://nakkaya.com 2010/6/27 José Luis Romero tangu...@gmail.com: Hi! I am learning the core of clojure, and so far, I am loving it. But I am not a lisp programmer (python, java, among others), but never functional programming. I am practicing with codingbat.com, coding the exercises on clojure. I am stuck with loops. I want to concatenate n times a string. For example, given the parameters 3 and code the output will be codecodecode. How can I do a loop in order to get this output. I know that this is a very newb question, any help will be appreciated. -- 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: Recur on a function which uses keyword arguments?
(defn countdown [ {:keys [from] :or {from 10}}] (println from) (when (pos? from) (recur {:from (dec from)}))) Passing {:from (dec from)} instead of :from (dec from) works. Regards... -- Nurullah Akkaya http://nakkaya.com On Sun, Jun 6, 2010 at 2:22 PM, Jonas Enlund jonas.enl...@gmail.com wrote: The function definition below fails with java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 1 args, got: 2 (defn countdown [ {:keys [from] :or {from 10}}] (println from) (when (pos? from) (recur :from (dec from Is it not possible to recur on a function which uses keyword arguments? If so, is using loop/recur the correct workaround? - Jonas -- 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: dump html with clojure
Yes but AFAIK you only get availableProcessors + 2 threads with pmap which is fine when the task is CPU bound but for downloading web pages most of the time will be lost at waiting for I/O so having more threads would speed things up. Regards... -- Nurullah Akkaya http://nakkaya.com On Thu, May 13, 2010 at 2:26 AM, Eric Schulte schulte.e...@gmail.com wrote: Wouldn't this be simpler with pmap, e.g. http://gist.github.com/399269 although to be honest I don't really know how the automatically parallelized clojure functions decide how many threads to use. Is the JVM smart enough to only create as many system-level threads as make sense on my hardware? Best -- Eric Nurullah Akkaya nurul...@nakkaya.com writes: Since you don't need coordination or keep some sort of state, IMHO future is better suited for this. Following gist is my take, it first reads the file that contains the list of URLs to be downloaded then splits the list into number of thread pieces. Each future object gets a piece of the list and start processing in its own thread. Each URL is written to disk using a UUID. http://gist.github.com/399127 Cheers... -- Nurullah Akkaya http://nakkaya.com On Wed, May 12, 2010 at 9:29 PM, nickikt nick...@gmail.com wrote: Hallo all, A friend of mine ask if there is a smart way to get the html code of couple thousand links but with a script, it takes for ever since it always has takes a couple of seconds to get the connection. I needs to be multi threaded so we can use all of the download rate. So I sad I could try it with clojure but I am pretty new in clojure and java (almost through the Programming Clojure book but nothing practical) and thought i just ask here instead of trying to copy some java code in clojure and hack something bad. My idea would be to span a agent for every dump and control that there won't be more then a 10-20 threads. And dump it into a file. How would you implement this? A function that does all of it in a agent and control it with a counter from a other function? Is there a clojure way to write a file or should I use the java way? Same for reading a file. Here is some javacode that does part of what I want. Is there a better way then proxy all of it? url = new URL(random page); URLConnection conn = url.openConnection(); DataInputStream in = new DataInputStream ( conn.getInputStream ( ) ) ; BufferedReader d = new BufferedReader(new InputStreamReader(in)); while(d.ready()) { System.out.println( d.readLine()); } Just that this prints to console instead of a file. So tanks for reading. I'm working on it any tip or suggestion would help. -- 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: Reading the manifest file
(let [url (ClassLoader/getSystemResource META-INF/MANIFEST.MF) manifest (java.util.jar.Manifest. (.openStream url))] (println (.entrySet (.getMainAttributes manifest ClassLoader/getSystemResource does allow you to get rid of Class/forName... -- 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: newbie hiccup with hiccup
Which version of hiccup? there was a bug discussed in compojure mailing list couple of days ago, where hiccup pre compilation fails when there are vars inside maps. http://groups.google.com/group/compojure/browse_thread/thread/d512a04a08aaa64f# 0.2.2 fixes this issue. -- Nurullah Akkaya http://nakkaya.com On Tue, Apr 13, 2010 at 5:52 AM, Micah Martin micahmar...@gmail.com wrote: Hey All, Does anyone know why the first expression below works but the second doesn't? What's the right way to do this? user= (use 'hiccup.core) nil user= (html (for [image [image017.jpg image021.jpg]] [:img image])) imgimage017.jpg/imgimgimage021.jpg/img user= (html (for [image [image017.jpg image021.jpg]] [:img {:src image}])) java.lang.RuntimeException: java.lang.RuntimeException: java.lang.InstantiationException: user$eval__209$iter__211__215$fn__216$fn__218$eval__220 (NO_SOURCE_FILE:3) (NO_SOURCE_FILE:3) Micah -- 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 To unsubscribe, reply using remove me as the subject. -- 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: How do I call Foo.class?
For analytics code which expects a call in Java like the following, AccountFeed accountFeed = analyticsService.getFeed(queryUrl, AccountFeed.class); I had to do this, (defn get-class [class] (Class/forName (str com.google.gdata.data.analytics. class))) Class/forName will return a java.lang.Class then you can pass it to the function, (.getFeed service url (get-class AccountFeed)) Hope it helps... -- 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 To unsubscribe, reply using remove me as the subject.
Re: How to separate code into different files
Assuming you have the following file structure, src/ src/tubes/ src/tubes/core.clj src/tubes/download.clj src/tubes/plugins/a.clj Now to use plugin a from core, (ns tubes.core (:use :reload-all tubes.plugins.a)) or to use download module from within plugin a, (ns tubes.plugin.a (:use :reload-all tubes.download)) src/ needs to be in your classpath. Regards, -- 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 To unsubscribe, reply using remove me as the subject.
Re: iterating over a nested vector
If I got you right this time, if you (apply interleave [[1 2 3] [2 5 1] [4 2 6]]) you will get, (1 2 4 2 5 2 3 1 6) then if you partition by 3, (partition 3 (apply interleave [[1 2 3] [2 5 1] [4 2 6]])) you get, ((1 2 4) (2 5 2) (3 1 6)) then as before applying max, (map #(apply max %) (partition 3 (apply interleave [[1 2 3] [2 5 1] [4 2 6]]))) will give you, (4 5 6) Regards, -- 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 To unsubscribe, reply using remove me as the subject.
Re: apply-ing Java methods
On Mon, Mar 8, 2010 at 9:47 AM, Michael Gardner gardne...@gmail.com wrote: Given a Java instance 'store' with a .connect method that takes a host, port, user and password, and given a hash-map 'config' with corresponding keyword values, I wanted to do something like: (apply .connect store (map config [:host :port :user :password])) rather than: (.connect store (:host config) (:port config) (:user config) (:password config)) but of course the former doesn't work, since .connect isn't a regular function. Is there a concise way to accomplish this? -Michael -- 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 Using this, http://paste.lisp.org/display/67182 would allow you to do, (let [config {:str fred :beg 2 :end 3}] (apply (jfn 'substring) (map config [:str :beg :end]))) -- 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: Got a Clojure library?
The name of your library clodiuno Library home page URL http://nakkaya.com/clodiuno.markdown Your name Nurullah Akkaya Category (db, web, UI, parsing etc) Physical Computing License Beerware Revision 42 A one-paragraph description. Include 3rd party dependencies if any. Clodiuno is a library that allows you to control Arduino via Firmata protocol. The purpose of this library is to allow Clojure developers to interface with real world using Arduino hardware. Dependencies: RXTX -- 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: #clojure irc
On Wed, Feb 17, 2010 at 6:10 AM, Brian Wolf brw...@gmail.com wrote: Hi, I was wondering if irc #clojure is open to anyone and if it is, what is the protocol? I get cannot send to channel error. I'm not familiar with irc. Thanks Brian -- 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 Freenodes new policy to fight spam. You need to register your nick. http://www.wikihow.com/Register-a-User-Name-on-Freenode -- 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: Getting started with few Java knowledge
check this out, http://github.com/nakkaya/clojure-stub it will create a bare bones Hello World! application, that you can build on top of, including an ant task for creating a jar file for your application. Regards, -- Nurullah Akkaya http://nakkaya.com On Mon, Dec 28, 2009 at 12:57 PM, Joop Kiefte iko...@gmail.com wrote: Hello folks, I have been learning a bit of Java at school a loong time ago (programming basics), when we were programming applets and I outscored all others with ease as I was the only one who could program already, and now I do android programming in Java, but I have never ever made a normal Java project, so I feel I'm missing some essentials to get started in Clojure when I want to create stand-alone apps. Can some of you maybe help me getting started on a Clojure project, e.g. the files I need to have to get it compiled nicely to a working JAR-package? (I use eclipse with CCW, but explanations for emacs are fine as well.) I have been looking online but I don't succeed well with the instructions found out there, I think it assumes too many knowledge of Java... Thanks beforehand, I would really appreciate your help (and don't be shy to make it verbose and full of hints ;)) Joop Kiefte, 20 yrs, the Netherlands -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- 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
Clojure meets Arduino
Hey guys, I have a small weekend hack, I thought it might be interesting. It is a pong clone including the ability to control it using knobs like the original. Part one goes over building the game, http://nakkaya.com/2009/12/19/cloning-pong-part-1/ Part two goes over building the controller hardware, http://nakkaya.com/2009/12/20/cloning-pong-part-2/ If you just want to play code is here, http://nakkaya.com/code/clojure/pong.clj And some footage showing the controllers in action, http://www.flickr.com/photos/nakkaya/4200386988/in/set-72157623036408444/ I would very much like to hear your feedback on the code. Regards... -- 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: is there a cannonical way to create executable jar files?
On Sat, Oct 24, 2009 at 10:50 PM, Richard Newman holyg...@gmail.com 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: !-- Build the classpath to point to any dependencies. -- manifestclasspath property=lib.list jarfile=${base.jarfile} classpath refid=manifest.path/ /manifestclasspath !-- Make the output jar with Main-Class. -- target name=solitary_jar description=Create jar with pointers to dependencies. depends=compile_clojure jar index=false jarfile=${solitary.jarfile} fileset dir=${base.build} includes=**/*.class,**/ *.properties/ manifest attribute name=Main-Class value=com.foo.bar/ attribute name=Class-Path value=${lib.list}/ /manifest /jar /target 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 -~--~~~~--~~--~--~---
clojure-stub
Hi, I have created a build.xml file to setup the directory structure and download the required jars. To have a running clojure application. All the required class path settings are taken care of inside the xml file, so you can have a running hello world jar in a couple of second. It is located at http://github.com/nakkaya/clojure-stub/tree/master Just clone and run ant setup. -- Nurullah Akkaya nurul...@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 -~--~~~~--~~--~--~---