Scala offers a method called stripMargin that removes the left-hand part of a multiline string up to a specified delimiter (default: "|"). Here is an example:
"""|Foo
|Bar""".stripMargin
returns the string
Foo
Bar
Is there a similar function in Clojure? If not, how would you implement it (most functionally)?
Thanks.
UPDATE: Th...
Hi!
I'm failing to import final classes from a java package. Importing normal classes works fine. For example:
gtk-examples.snooping> (import 'org.gnome.gdk.MouseButton)
org.gnome.gdk.MouseButton
gtk-examples.snooping> (import 'org.gnome.gdk.ModifierType)
; Evaluation aborted.
gtk-examples.snooping>
The last import yields a NoClass...
I wondering if there is a set of Emacs Lisp code that implements some of Clojure's functions. For example, -> and ->> and comp and partial, and others?
Thank you.
...
I have a small compojure site, with the routes defined as such:
(defroutes example
(GET "/" [] {:status 200
:headers {"Content-Type" "text/html"}
:body (home)})
(GET "/*" (or (serve-file (params :*)) :next))
(GET "/execute/" [] {:status 200
:headers {"Content-Type" "text/html"}
...
Command line is "D:\Progra~1\Java\jre6\bin\java.exe -jar D:\Old\Clojure\clojure.jar D:\Old\Clojure\clojure-contrib.jar"
Following error appears:
clojure.lang.Compiler$CompilerException: clojure-contrib.jar:0: Unable to resolve symbol: PK♥♦ in this context
clojure-contrib version is 1.1.0
How to invoke clojure with libraries right?
...
From reading introductory material on Lisp, I now consider the following to be identical:
(list 1 2 3)
'(1 2 3)
However, judging from problems I face when using the quoted form in both Clojure and Emacs Lisp, they are not the same. Can you tell me what the difference is?
...
I noticed that (use 'somemodule :reload) doesn't reload the module if the .clj file was not modified.
However I have an usecase for forcing the reload of the module even if the file isn't changed. I created a haml macro for clojure which reads an external file and generates clojure code.
( http://www.coldcode.net/2010/10/haml-macro-for...
I am creating trees of s-expressions for a genetic programming problem, and need to alter parts of the trees during the evolution process. I came across the Clojure zipper function that seems like it should be perfect, but for the life of me I can't figure out how to use it.
For example, say I create a zipper with
(def zipped (zip/seq-...
Is there a language specification for clojure? Something that precisely defines the lexical syntax and grammar in EBNF or something similar?
The closest thing that I could find is the clojure website, but that doesn't really quite meet the requirements of a language spec (despite being an absolutely wonderful resource). If there is no...
EDIT Updated code with solution
I need to transcode amr to mp3, so i wrote a gstreamer pipeline in gstreamer-java. It looks like this:
src ! amrparse ! amrnbdec ! lamemp3enc ! sink
(actually built with the java API, of course), i start the transcode with
Bus.connect(EOS, fn(){Gst.quit();});
setState(PLAYING);
Gst.main();
It wo...
What's the difference between Cake and Leiningen?
...
I'm trying to write a function that returns a memoized recursive function in Clojure, but I'm having trouble making the recursive function see its own memoized bindings. Is this because there is no var created? Also, why can't I use memoize on the local binding created with let?
This slightly unusual Fibonacci sequence maker that starts...
I'm looking for a profiler for the JVM similar to Python's "run snake run". The feature I'm missing the most is the "square map" visualization showing which methods are taking the most time to run.
http://www.vrplumber.com/programming/runsnakerun/screenshot-2.0.png
Any suggestions?
...
Hi,
Does anyone know if there is a straightforward way to serialize a parsed cyberneko ElementNSImpl object?
Here is my example in Clojure of serializing the whole DOM (an HTMLDocumentImpl object). This works, but I have not yet figured out how to do this for an element from the dom (ElementNSImpl).
(defn dom->xml
[dom]
(let [sw ...
I've written a little internal webapp that I use to import invoices from our jobcard database into MYOB. I've written it using Clojure and Compojure, and it actually works pretty well, and it was also a good learning exercise for me.
However, I've got a problem, it seems that after a successful invoice import the jetty server will no l...
found this on a blog : (def x ^{:type ::my-class} {})
apparently it adds meta data to a map
user=> (meta x)
{:type :user/my-class}
what else does ^ do ? does it have any other uses ? can it be used as a getter for meta data (not just to set meta data) ?
how can i find out information about some shortcuts in clojure ? like ^, ', `, ~...
It seems that Clojure 1.2.0 has a definterface form, apparently for creating Java interfaces, and some people recommend using it (e.g. one answer to this number crunching question). However, I cannot seem to find any documentation or substantial examples of how to use it. Am I not looking in the right place, or is it actually such an ear...
Are the JavaDocs for clojure.lang, etc. available online? Do I need to build it myself from the Clojure source?
Thanks.
...
Trying to understand if types imply OO and vice versa.
Questions:
What exactly is a type ?
Can a class in ruby be called a 'type'.
In javascript, the native functions/objects like Array,String,Function ... Are they types ?
Is a C struct a type ?
How is it that a language can be typed even when it doesn't support OO ? For e.g. H...
What I'm looking for is this kind of command line interaction at the Windows command line:
C:\temp1>clj some_script.clj
C:\temp2>
Where some_script.clj contains something like:
(cd "c:\\temp2")
So the question is - how do I implement the function cd? Have experimented with clojure.java.shell, but it does not look like the lib I nee...