Hello,
Clojure newbie here. I'm porting a small Scheme matrix/linear algebra
library over to Clojure as a way to get familiar. In my scheme lib, I
have a (matrix-mult A B) function, but it would be nice to have the
more standard notation (* A B) or (* 3 A) for scalar multiplication.
I see *, /,
>
>> Alternatively, could I provide a "multi-
>> math" lib to redefine the core math functions?
>
> Type classes would be king.
Do you mean this in the Haskell sense? (I'm not too familiar with
those) Or something more like Java's types? I was thinking about how
to solve this problem more gen
>
> For (1), it seems you generally resort to some kind of recursion with
> loop/recur. Say we wish to find the max value in a list (without using
> 'max'):
I can do this with reduce:
user=> (defn my-max [lst] (reduce (fn [x a] (if (> x a) x a)) (first
lst) (rest lst)))
#'user/my-max
user=> (my
> This release should facilitate everyone using the same post-AOT API,
> and brings us closer to the 1.0 release. I'll be going through the
> docs to bring them up to date. If you are using an old release, please
> move to this one, as it is what the documentation will reflect moving
> forward.
R
Time for another person named Mark to chime in. I expect to hear from
all the other Marks before this thread is over.
I have three responses to your suggestion:
1. Data: Is this really a problem that is slowing down Clojure
programs in practice? Can you provide some data to that effect? I
I suggest moving friendship outside of the objects themselves.
(defn person [name] {:name name})
(def bob (person "Bob"))
(def bill (person "Bill))
(def *friends* {bob bill})
now friends is a map of who likes whom. Then you can implement
(defn friend? [p1 p2] (or (= p1 (*friends* p2)) (= p2 (*
I can't imagine this idea will be met warmly, but I have a suggestion.
It requires ending maps and vectors as functions of keys. Instead,
make the first argument to a collection be a function which is mapped
to across the collection. Any additional arguments are passed to the
function on e
GNU Lesser GPL, which is consistent with
JFreeChart's license.
The code can be found at: http://www.markmfredrickson.com/code/
Best wishes,
- Mark Fredrickson
mark.m.fredrick...@gmail.com
http://www.markmfredrickson.com
--~--~-~--~~~---~--~~
You receive
shows
> again: ugly solutions and special cases are a sign,
> that one does it wrong...
>
> Please find attached another patch going for IRef instead
> of Var directly. And without the other cruft.
>
> Sincerely
> Meikel
>
>
- Mark Fredrickson
mark.m.fredrick...@gmai
> It could be that the two threads are contending over the Array object
> reference (Java arrays aren't pointers). Is there a nice way to
> create "subvector" objects that only reference the underlying memory
> and not the parent array object?
You might be interested in the *Buffer classes (e.g.
rts, scatter plots, histograms, etc).
- Mark Fredrickson
mark.m.fredrick...@gmail.com
http://www.markmfredrickson.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group,
level watcher seems like the most Clojure-ish
solution.
Thanks in advance,
- Mark Fredrickson
mark.m.fredrick...@gmail.com
http://www.markmfredrickson.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Cloj
(list form x)))
> ([x form & more] `(pipe (pipe ~x ~form) ~...@more)))
>
>
> I've seen pipe written as a function with the use of reader macros, or
> as macros built from scratch. I'm putting this one forward because the
> tiny change in intention from &
ot;->" macro (defined in
>>> core.clj, line 984), swapping "~@(rest form) ~x" to "~x ~@(rest
>>> form)":
>>
>>> (defmacro pipe
>>> "Threads the expr through the forms. Inserts x as the
>>> last item in the first for
e:
>> Hi,
>> Is there a built-in function that will return thefirstitemin a
>> collection that matches a predicate? (Something equivalent to Ruby's
>> Enumerable#find...) Seems pretty basic, but I can'tfindit in the
>> docs.
>&g
>
> Maybe _ is appropriate?
>
> => (let-> _ (+ 1 2) (* 2 _) (+ _ 1))
> 7
> => (let-> _ [1 2 3] (map inc _) (reduce + _) (+ _ 3))
> 12
>
> Or maybe ? ?
Don't forget the wide variety of unicode symbols you have at your
disposal:
user=> (let-> ★ 2 (+ ★ 3) (- 10 ★ ) (map #(* ★ %) [2 3 4]))
(10 1
st argument is the keyword :last it behaves like pipe. This
would be backwards compatible with the current -> implementation, but
also allow for the additional functionality described in this thread.
I think a good implementation would be to have the
While (read) taking an argument seems valid, I think you can do what
you want in the short term using binding:
(binding [*in* my-reader]
(print (read)))
It has been my general observation that vars + binding in Clojure fill
the niche that optional arguments fill in other languages. While it
ma
Previous to my discovering Clojure, I wrote a small Scheme library to
embed concatenative programming inside a Lisp:
http://www.call-with-current-continuation.org/eggs/3/stacktor.html
I ultimately found that I didn't use it much when I was writing real
programs, but it was a good way to learn ab
So far most of the action has concerned arithmetic ops (+, -, *, /).
Will these new semantics include the bit-shift operators? I vote yes.
My use cases for bit ops would benefit from primitive ops.
On a related note, my use cases call for silent overflow of bit shifts
(pseudo random number generat
On Jun 29, 5:43 pm, nickikt wrote:
> We could make it possible to add some metadata to a function
> like :example or something. Then add a function called (example
> ) to print the example.
>
> Everybody could send patches. It would be a good way to learn and a
> good extra doku.
I was consider
> It's a great start. However, examples are much more useful if you know
> what they should produce. run-examples might provide that, but having
> them in the metadata would be even better - along with an explanation.
>From my original email:
=== Examples ===
> (foo 1 2)
3
> (foo 3 4)
7
B
Hello Tim,
> Knuth originally created an idea of literate programming
> where you embed source code into latex documents. He called
> such documents "web" documents (because nobody had yet used
> the word "web").
Thanks for passing along your code. I have some familiarity with
noweb. I use Sweave
On Jul 7, 2:05 pm, John Cromartie wrote:
> I've whipped up a proof-of-concept of how to implement built-in
> examples for functions and macros.
I've been poking at something similar:
http://github.com/markmfredrickson/postdoc
In my version, examples can be either strings or quoted code. If you
> I'd be perfectly happy with a LaTeX-based solution, although I
> understand the appeal of something more "within Clojure".
I've been playing with a Clojure solution:
http://github.com/markmfredrickson/changeling
I just pushed a version to clojars as well.
> As a first approximation, literate
Perhaps you would be interested in postdoc:
http://github.com/markmfredrickson/postdoc
Postdoc allows structured documentation, runnable examples, and
related items based on namespaced identifiers. One was to allow for
separate files that included the documentation away from the code, so
as not
I will put in a plug for my much neglected "postdoc"
https://github.com/markmfredrickson/postdoc
This takes the :examples approach (though it namespaces it within
another map: metadata -> :postdoc -> {:examples "..." :see-also
"..." }).
Some ways to focus your effort would be to start a project
Hello,
I have a web survey/survey experiment written in Clojure. The survey is
currently in English and needs to be translated into French as well. Since
the program has a relatively short life span (only a few weeks) and to make
life easiest for my translator, I figured my best solution would
Thanks for the suggestion. This ended up being just what I was looking for.
I wrote a version that used this, then went to try the analyze library
recently announced (in hopes of getting line numbers). The analyze library
depends on a beta release of Clojure 1.4, and I decided just to stick with
Does app.two.b have a hyphen? If so, make it an underscore when importing.
I've been bitten by that issue before.
Also, +1 to correct names suggested by Vinzent.
-M
On Thursday, April 12, 2012 1:03:49 PM UTC-5, Adam Markham wrote:
>
> I have two namespaces as follows:
>
> (ns app.one.a
>
user=> (defrecord Foo [a])user.Foouser=> (def a (Foo. 1))#'user/
auser=> (def b (Foo. 2))#'user/b
user=> (defrecord Other [b])
user.Other
user=> (def q (Other. 123))
#'user/q
user=> (def p (Other. 456))
#'user/puser=> (filter #(= (class %) user.Foo) (map var-get (vals (ns-
publics 'user
(#:user
Hello,
I am working on a DSL for a non-technical crowd hosted in Clojure. The
first major hurdle for my users to tackle would be installing Clojure,
a text-editor, and learning the workflow. I'd like to make this as
easy as possible, so I'm considering a web app solution instead of a
desktop app.
Thanks to one and all for the replies. For the moment, I'm going to
concentrate on the DSL itself and start puttering with a Clojure
parser for CodeMirror (http://codemirror.net/), a JavaScript text
editor, which should be simplified by cribbing from the Scheme parser
implementation. This is someth
Is the following behavior correct or a bug:
user> (defrecord Example [data] clojure.lang.IFn (invoke [this] this)
(invoke [this n] (repeat n this)))
user.Example
user> (def e (Example. "I am e"))
#'user/e
user> e
#:user.Example{:data "I am e"}
user> (e 2)
(#:user.Example{:data "I am e"} #:user.Exa
Thank you. That seems to do the trick.
-Mark
On Feb 7, 11:55 pm, Alex Osborne wrote:
> Mark Fredrickson writes:
> > Is the following behavior correct or a bug:
>
> > user> (defrecord Example [data] clojure.lang.IFn (invoke [this] this)
> > (invoke [this n] (repeat
I wanted to see how long this thread would go before someone linked to
the old stuff. :-)
Despite turning up repeatedly, the issue has never been put to bed. I
suspect it is the name. There has been no consensus, as this thread
demonstrates. I vote for one I haven't seen yet. `=>`. It's two
charac
Hello friends,
I am writing a program to generate directions for humans to read. The
directions are composed of a collection with a series of steps, some
of which may be duplicated:
[:a :b :c :a :b :c]
I would like to compress them by indicating repeats, using this
notation:
[[2 [:a :b :c]]
Si
Thanks for the hint on LZ77. That was exactly what I was looking for.
Thank you also to the others who provided this and other answers.
Thanks!
-Mark
On Feb 13, 1:00 pm, Mark Engelberg wrote:
> This is essentially a compression problem. I think you want to research the
> topic of "Run-length
Very interesting solution. I implemented an LZ77 like solution, which
appears to be working, but its good to have alternative solutions. As
you point out, different match patterns might be interesting. I tune
the matching by disallowing small matches based on length, but the
pattern string would be
39 matches
Mail list logo