Hello,
I'm new to Clojure, SLIME, and emacs in general but I've noticed my
SLIME REPL does not indent properly when I use or C-j. This
is the error message I see:
"calculate-lisp-indent: Symbol's function definition is void: clojure-
indent-function"
I've experienced this when setting up Cloju
Thanks Bill. That's just what I needed.
On Jan 15, 7:58 am, Bill Clementson wrote:
> Hi Kyle,
>
>
>
> On Wed, Jan 14, 2009 at 11:27 PM, Kyle Smith wrote:
> > I'm new to Clojure, SLIME, and emacs in general but I've noticed my
> > SLIME REPL does no
I have improved on chouser's gview code (http://blog.n01se.net/?
p=30). It can now expand java.awt.Container objects. I haven't
implemented this, but it would be nice to pass in a function to filter
leaves/nodes.
(defn container? [obj]
(instance? (. (java.awt.Container.) getClass) obj))
(ns
The selections function in combinatorics returns more than what I
need. (selections [ 1 2 3 4 5] 3) will return both (1 2 3) and (3 2
1), etc. However, I still need (1 1 1) (2 2 2), etc. I've tried
several times to write a function to filter out the 'duplicates', but
haven't quite got it.
--~--
Ok, I'm an idiot. All I needed was (remove #(< (last %1) (first %1))
(selections [1 2 3 4] 3))
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@googlegrou
In general, this function will work for non-integer collections. I
make no performance/laziness guarantees.
(defn selections-dups [coll n]
(let [r (range (count coll))
f #(< (last %1) (first %1))
s (remove f (selections r n))]
(map #(map (fn [x] (nth coll x)) %1) s)))
--~--
(map #(doto %1 (.add 2)) (doto (new java.util.ArrayList) (.add 1)))
This seems like it should work, but does not. Can anyone confirm?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this
I often need to call a java method on each element in a collection. I
didn't find anything on the group, so I wrote a macro.
(defmacro map-method [method coll & args]
"Calls the given method on each item in the collection."
`(map (fn [x#] (. x# ~@(if args
(concat (li
Of course those would work, but I got sick of typing them over and
over.
(map-method length ["mary" "had" "a" "little" "lamb"])
(map-method indexOf ["mary" "had" "a" "little" "lamb"] (int \a))
I find typing # and % repetitive, so this is just a little syntactic
sugar.
--~--~-~--~~---
+1 as well for pipe and let->
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to
clojure+unsub
I tackled this exact problem a few days ago. My solution was to use
atoms (very poorly). My code is on the group as bsptree.clj
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group,
I'm trying to map across code, but map evals each item in the list.
I've been trying to re-implement map as a macro, but so far no
success. Is there some way to accomplish this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Googl
Well, I'm just doing some exploratory programming, so I don't really
have anything yet.
I'd like to do something like (map a-macro some-code)
What I can't do is (map #(a-macro %) some-code) because % evals each
code fragment.
--~--~-~--~~~---~--~~
You received this
"It would also break the compatibility of rest with Common Lisp's"
This is of mild concern to me, but I think if there was a prominent
warning on clojure.org, I could get over it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Goog
I wrote some functions to streamline reflection here.
http://groups.google.com/group/clojure/browse_thread/thread/ea23cd11b7bd8999/f32795d9a79eeeb9?lnk=gst&q=accessing+private#f32795d9a79eeeb9
--~--~-~--~~~---~--~~
You received this message because you are subscribe
See repl.clj in the files section. I've embedded it in a few of my
apps, and it's quite nice.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@googlegroups
I've uploaded tree-utils.clj to the files section.
http://groups.google.com/group/clojure/web/tree-utils.clj Here are
some example usages:
Subtracting two (or more) trees element-by-element:
user=> atree
[[1 2] [3 4 5] [6 7]]
user=> btree
[[2 3] [4 5 6] [7 8]]
user=> (tree-reduce - atree btree)
Sounds good. Unless there are other suggestions, can someone make the
minor changes and commit it to contrib?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to cloj
I have uploaded 3d-viewer.clj to the files section. If anyone finds
it useful, I would appreciate some feedback.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to c
Import statements added. Example usage:
(def coords [[0 0 0] [1 1 1] [2 2 2]]);etc
(g3d coords)
That should pop open the viewer. Left click and drag to rotate, and
use the scroll wheel to zoom in/out.
--~--~-~--~~~---~--~~
You received this message because you a
user> (def nums '(1 2 3))
#'user/nums
user> (def funs '((+ (1 2 3)) (- (1 2 3
#'user/funs
user> funs
((+ (1 2 3)) (- (1 2 3)))
user> (def funs `((+ ~nums) (- ~nums)))
#'user/funs
user> funs
((clojure.core/+ (1 2 3)) (clojure.core/- (1 2 3)))
I would expect these two approaches to be the same,
Ahh, of course. I've actually learned that trick before. 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
To unsubscribe from this
I have written code that will randomly guess the mathematical form of
a list of xy ordered pairs. My code and a sample run are in guess-
check.clj in the files section. The final sum of squares is
fantastic! This code is just for fun, but I would appreciate some
feedback.
--~--~-~--~---
Thanks for the feedback Daniel, I've incorporated your ideas and re-
uploaded. I'm not sure where you're seeing mutable data structures.
Anyhow, I now only call eval once each time scorer is called, which is
massively faster.
This has allowed for additional testing points, and now I get a
perfec
How about (map - seq1 seq2) ?
An example or two of the desired output would be helpful.
--~--~-~--~~~---~--~~
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
No
I have generalized the code to allow more than one independent
variable. The calling convention has changed: instead of separate x
and y seqs, there is one "xylist". Each element of xylist is a tuple
containing the dependent variable *first*, and then any independent
variables.
I haven't had ti
I just took a quick look, but string-to-seq can be defined as (re-seq
#"\S+" string), and similarly for string-to-map.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email
> I am dealing w/ some performance constraints in the current
> implementation of my application.
More information, please. What in general is your app? What are the
specs of your machine? What kind of data does your app deal with?
> So, although Clojure offers some
> features that would solv
I read Norvig's PAIP. The concept of first defining a dsl and then
writing an interpreter/compiler for it is amazing. Even something as
simple as his sentence grammar shows the idea.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
I would summarize your text as "misguided". If you're using lisp/
clojure simply as a replacement for things that you can do in other
languages, then it's not going to look as attractive. You seem to
touch on that when you talk about code generating code, but I don't
think you really understand
I needed the functionality of merge-with, but need f applied in all
cases. This version only works for 2 maps, but you can use reduce for
more maps. This lets me incrementally build up maps whose vals can be
seqs.
(defn always-merge-with [f amap bmap]
"Like merge-with, but always applies f"
On Jun 30, 2:41 am, fft1976 wrote:
> I would be curious to know if anyone is using Clojure for CPU-
> intensive work where performance really counts.
I'm using clojure for various computational physics tasks:
1. I'm writing a dsl for substructure searching.
2. I'm doing classical molecular dynam
> I am guessing I need to start reading and using macros at this point?
I also wrote something to do symbolic regression. I used plain
functions to manipulate quoted trees, and one macro to wrap the
expression in a fn and eval.
--~--~-~--~~~---~--~~
You received t
I wrote these and thought they might be useful. Feel free to add them
to clojure.contrib.seq-utils
(defn flatten-n [n coll]
"Like flatten, but only goes n levels deep."
(if (= n 0)
coll
(recur (dec n) (apply concat (map #(if (sequential? %) % (list %))
coll)
(defn- unflatten* [t
I'm trying to use Stuart Sierra's implementation of cells. I want to
sum the values of a large number of cells. Rather than linearly
summing all the values, I would like to create a tree of cells whose
root contains the sum. I added the function commute-cells:
(defn commute-cells [f cells]
(
I'm trying to learn how to use zippers, and I have some thoughts: Why
does (root loc) return a node, rather than just the location of the
root? If the latter were true and you wanted the node, you could just
call (node (root loc)). As it is, once you call (root loc), you lose
the reference to t
> At the moment "root" works like an "unzip". What you want it is some
> kind of "up-till-root" shortcut.
Yep. For now, I've added root-loc to my local copy of clojure,
although I second the name unzip.
> > It would also be nice if the docs mentioned that a loc is a vector of
> > [node path].
>
>
> It looks to me like you are blowing the stack. You may want to rethink
> your commute-cells function so that it either uses the 'recur'
> operator and is tail recursive, or uses a trampoline of some sort.
When you blow the stack, you'll get an exception saying so, and it
usually happens pretty
You'll want to look at the -> macro. Read http://clojure.org/data_structures.
You can also omit nth in two cases.
(let [nestedDS ["foo", {"hi" "there", "hello", ["buddy"]}, "hi"]
foo (nestedDS 0)
there (-> nestedDS (nth 1) (get "hi"))
buddy (-> nestedDS (nth 1) (get "h
Sounds like a cool project. Have you thought about adding peephole
optimization? For example, the form (map inc (map inc (range 1000)))
should be equivalent to (map #(+ 2 %) (range 1000)). I believe there
are automated methods, but it could even be as simple as a pattern-
matching, rule-based t
> He has no other solution than to audit all his code
> to locate (not necessarily a trivial task) and update the
> destructuring patterns which concern foo data.
As mentioned, this is a problem in any language. However, clojure lets
you do things in much, much less code, so I don't think it
I've dabbled in genetic programming as well. My approach to crossover
is simply to return a seq of indices to the node. Then you can just
use nth repeatedly, or if your trees are nested vecs, you can use
assoc-in directly. Then I just eval'd a fn and map-reduce'd it across
my test data.
--~--~-
I wrote this based on assoc-in. If anyone thinks this should be in
core or contrib, feel free to use it.
(defn assoc-in-by
"'Updates' a value in a nested associative structure, where ks is a
sequence of keys and (f v) is the new value and returns a new nested
structure.
If any levels do no
haha, the api page strikes again! I figured something so basic would
have to be included, but I obviously didn't see update-in. It would
be nice to have a list of related functions that do not follow the
standard nomenclature. Will the upcoming documentation push address
this?
--~--~-~-
Are you calling System/exit when you close a window? Why not just do
(.setDefaultCloseOperation jframe JFrame/DISPOSE_ON_CLOSE) ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group
Why not just use http://clojure.org/api#sorted-map ?
--~--~-~--~~~---~--~~
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 m
See this thread on the clojure-dev group:
http://groups.google.com/group/clojure-dev/browse_thread/thread/8fe671d08d8e275c#
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send e
repl.clj in the files section of the group is exactly what you 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 n
Clojure data structures can be printed to a string, and the string can
be read back in as a data structure.
user> (def a {:key1 "string" :key2 #{"set" "of" "strings"}})
#'user/a
user> a
{:key1 "string", :key2 #{"set" "strings" "of"}}
user> (def b (str a))
#'user/b
user> b
"{:key1 \"string\", :key
select returns a set, so you need to call seq/vec before calling nth.
user> (nth (seq (clojure.set/select #(zero? (mod % 2)) #{1 2 5 10}))
0)
2
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post
clojuratica works with the free mathematica player. I don't think
there are any licensing issues, but I could be wrong. I need to do
more benchmarking, but the performance is pretty good so far.
--~--~-~--~~~---~--~~
You received this message because you are subsc
Rather than the number of nodes in a tree, I think a better metric
would be the number of edges in a graph. Variables that are
referenced on many different lines should get double counted. I think
this would explain why imperative spaghetti code is so complex. On
the other hand, I suspect func
What's wrong with (map + [31 41 59 26] (iterate inc 1)) ?
(use 'clojure.contrib.seq-utils)
(defn sliding-window [coll size]
(let [idx (into {} (indexed coll))]
(map #(vals (select-keys idx (range (- % size) (+ % size 1
(range (count coll)
This is the same as your second
I'm having some trouble with Alex's macro. I can type in the debug-
repl, but when I hit enter, it just hangs and nothing happens.
--
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
Yes, I just figured that out. Is there a way to use this with slime?
--
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
I also vote for static analysis. People have combined static analysis
with data mining to predict software defects.
http://scholar.google.com/scholar?hl=en&q=data+mining+software+defects&btnG=Search&as_sdt=2000&as_ylo=&as_vis=0
However, it doesn't look like anyone's tried it with any functional
la
Martin, you're trying to argue that some hypothetical 'unwashed
masses' of programmers won't like clojure because of parenthesis. The
problem is you're just assuming it's the parenthesis, and there is no
way to know for sure (short of a peer-reviewed study). Maybe java
programmers don't know abou
Here's the macro I used when I dabbled in Genetic Programming:
user> (time (dotimes [_ 1000]
(intern 'user 'x (rand))
(eval '(+ (* x x) 5
"Elapsed time: 425.754877 msecs"
user> (defmacro capture-vars [vars expr]
`(fn [...@vars] ~(first (next expr
#'use
I haven't touched it in a while, but I'm going to pick it back up soon.
--
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 wi
It's a little shorter if you unconditionally concat & repeat.
(defn append-val [val & colls]
(let [maxlen (apply max (map count colls))]
(map #(concat % (repeat (- maxlen (count %)) val)) colls)))
user> (apply map + (append-val 0 [1] [2 3] [4 5 6]))
(7 8 6)
--
You received this message be
This isn't fully tested, but it should work. Lisp doesn't need
fixing.
(defmacro switch [choice-seq & clause-maps]
(let [choice (first choice-seq)
clauses (map #(apply concat %) clause-maps)]
`(condp = ~choice ~@(apply concat (map (fn [clause]
[
First, make sure you have -server. If you can spare more heap, use -
Xmx1g . If you're on a 64bit jvm, -XX:+UseCompressedOops adds a
significant boost. A flag that helps quite a bit is -XX:
+DoEscapeAnalysis . Finally, if you want to play around with the JIT
threshold, use -XX:CompileThreshold=n ,
http://groups.google.com/group/clojure/browse_thread/thread/806ebb1cbe671969/82a25385a2a8a18d?lnk=gst&q=unflatten#82a25385a2a8a18d
--
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 p
user> (defn inc-vals [m]
(into (empty m) (zipmap (keys m) (map inc (vals m)
#'user/inc-vals
user> (inc-vals {:a 1 :b 2})
{:b 3, :a 2}
user> (inc-vals (struct (create-struct :a :b) 1 2))
{:a 2, :b 3}
user> (= *1 *2)
true
So what's the problem (other than printing differently)?
--
You
On Apr 8, 10:56 pm, Phil Hagelberg wrote:
> You'll notice 90% of the "I'm having trouble with Emacs" posts have
> one thing in common: they all start with "I'm trying to install
> without ELPA".
You're assuming people haven't already tried ELPA before resorting to
manual installation. I tried li
I think the root of the misunderstanding is this: doto is NOT -> or -
>>
doto is typically used for initializing mutable java objects. So,
instead of (let [foo ...] (.bar foo) (.baz foo) foo) , you can use
(doto ... .bar .baz) It looks like you're trying to return the value
of the last expressio
On Aug 19, 12:08 pm, Brian Goslinga wrote:
> Here is another trick that works for me in Emacs: delete most of the
> stack of closing parens, and then spam the ) key until the Emacs
> matches it to the desired opening paren.
this.
--
You received this message because you are subscribed to the G
> What are you doing with Clojure?
I'm trying to write a DSL for molecular dynamics analysis (with
partial success). Users will be able to compose complex properties
from basic info such as bond lengths/angles, position, velocity, etc.
I'd like to add regression and integrate it with a 3d viewer
Maybe you could attach a cell to a JComponent and call setEnabled as
necessary.
--~--~-~--~~~---~--~~
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
To unsubsc
69 matches
Mail list logo