On Feb 12, 9:51 pm, Michael Gardner wrote:
-snip-
> Those are all good, but ...
Before I pointed out that code size was already shown, you thought
just including such a measure would possibly "do the trick" but now
that seems not to be good enough for you.
> how many people actually look at an
Hi,
Yes I can reproduce the bug on MacOS too. I have added :main
textmash.core to project.clj. Now after: lein run, the GUI starts and
all implemented functionalities work fine, but in console I get:
Exception in thread "main" java.lang.NullPointerException
(NO_SOURCE_FILE:1)
at clojure.l
On 12 February 2011 18:56, Seth wrote:
> As the question states - why doesnt defrecord support java class
> inheritence? Is it just because people think it wouldnt be 'good' or
> are there true technical issues with doing it?
It's a design choice. Some languages tie together the concepts of
inher
I have a statemap with a couple of infinite lazy-seq.
When doing testing I want to check states for equality.
This of course fails on the whole infinite thing.
The sane thing is taking only the first item from the seqs when doing the
equality check.
How would I accomplish this in the easiest way?
Redefining equality is not something to be taken lightly. It can break in
subtle ways with identity and hash codes.
You may want a custom equality function, like "equal up to n elements of a
sequence," for use in your tests.
-Stuart Sierra
clojure.com
--
You received this message because you
I believe there are some technical issues with allowing re-definition of a
class that inherits from a concrete (non-interface) superclass, but I don't
know the details.
However, it was mainly a design decision. Clojure is opinionated, and one
of its opinions is that concrete inheritance is bad
Modern JVMs like HotSpot are very good at eliminating unnecessary
instructions. Unfortunately, I haven't heard of a good tool for observing
this process, so you either have to take it on faith or go read the OpenJDK
source code.
-Stuart Sierra
clojure.com
--
You received this message because
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
Here's one:
user=> {:a 1 :b}
#
Instead how about a parse error exception that specifically says
something like, "Map literal requires an even number of forms."
Thanks,
Jeff
On Feb 8, 3:01 pm, Stuart Halloway wrote:
> This conversation began on Twitter [1] but I want to continue it on the
> ma
Thanks again to Alex for helping me with my Clojure mojo in order to
get around a ClassCastException. I'm writing to request a code review
of my simple "Hello, world!" genetic algorithm simulator written in
Clojure. I've written an implementation in Java and I have used that
as the basis for my C
This is essentially a compression problem. I think you want to research the
topic of "Run-length encoding", and then look at algorithms like LZ77 which
handle runs of repeated characters. LZ77 finds repeated blocks that are
some distance apart; so, for example, you could restrict the algorithm to
On Feb 13, 2011, at 10:11 AM, Mark Fredrickson wrote:
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 ind
DEFLATE is a compression method that combines LZ77 with Huffman
coding. It is implemented in java.util.zip.
Read about it here:
http://download.oracle.com/javase/1.4.2/docs/api/java/util/zip/package-summary.html
fpc
--
You received this message because you are subscribed to the Google
Groups "
Hi, clojure newbie here;
I have a quick question, I am writing a small pattern matching program
and I can't figure out how to append a string to a # for re-matcher:
(.replaceAll (re-matcher #"ATGCCC" my_String) replacement_String)
When I try (string? #"ATGCCC") it returns false.
# isnt a macro
Roger that.
Thanks for the help.
2011/2/13 Stuart Sierra
> Redefining equality is not something to be taken lightly. It can break in
> subtle ways with identity and hash codes.
>
> You may want a custom equality function, like "equal up to n elements of a
> sequence," for use in your tests.
>
* I think io-loop function can be improved/simplified.
* I usually don't like duplication (.readLine in) is being repeated in
io-loop.
* any other comments/links/reference to some other idiomatic code are
welcome.
(ns echo.server
[:use clojure.contrib.server-socket clojure.java.io
clojure.contri
Christopher Maggio writes:
> Hi, clojure newbie here;
>
> I have a quick question, I am writing a small pattern matching program
> and I can't figure out how to append a string to a # for re-matcher:
Not quite following, but check out re-pattern
(http://clojuredocs.org/clojure_core/clojure.core/r
Hi,
you may be interested in reading the code from our book which a) includes
the code for doing exactly what you did (evolve a string) and b) shows how
multithreading can change your way of doing GAs (get rid of the concept of
generations).
The book and the code are written in German which ma
Thanks, just what i was looking for!
-Chris
On Feb 13, 9:04 pm, Fred Concklin wrote:
> Christopher Maggio writes:
> > Hi, clojure newbie here;
>
> > I have a quick question, I am writing a small pattern matching program
> > and I can't figure out how to append a string to a # for re-matcher:
>
Cool, thats what I thought. Sometimes, i wish i could inherit from a
class, but then i just use proxy to do it instead :) For example, i
made a function which acted like a fn? , but had some metadata. At
first i was going to use records, but couldnt because i needed to
inherit from Afn, but proxies
I have an application which contains a number of running threads, each
which has a state to it. A state is a single record. It contains some
random stuff, but most importantly it a has a :var slot which contains
a map in which the keys are vars and the values are whatever the vars
are (if they can
On Sun, Feb 13, 2011 at 7:00 PM, Seth wrote:
> Cool, thats what I thought. Sometimes, i wish i could inherit from a
> class, but then i just use proxy to do it instead :) For example, i
> made a function which acted like a fn? , but had some metadata. At
> first i was going to use records, but cou
I already have code which uses fn? everywhere. So i needed to inherit
Fn interface. Adding metadata to the function (basically, an id) was a
necessary afterthought. Basically, im using an emacs like hook
interface for the gui end of my application, so its hightly
configurable - but i need to know w
oh, and of course the funuction needs to be executable (they are after
all just functions with metadata) - so we cant use ifn?, which would
return true on record!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo
And just for the heck of it, if anyones interested - heres the hook
code.
(ns forex.util.emacs))
(defmacro is [val & message]
`(let [result# ~val]
(if (not result#)
(throw (Exception. ~(or (and (first message) `(format
~@message)) (format "assert: %s" (str val)
result#)))
and of course i forgot to include some utility functions. oh well...
--
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
On Sun, Feb 13, 2011 at 8:39 PM, Seth wrote:
> I have an application which contains a number of running threads, each
> which has a state to it. A state is a single record. It contains some
> random stuff, but most importantly it a has a :var slot which contains
> a map in which the keys are vars
On Sun, Feb 13, 2011 at 10:14 PM, Seth wrote:
> oh, and of course the funuction needs to be executable (they are after
> all just functions with metadata) - so we cant use ifn?, which would
> return true on record!
The map? function also returns true on a record, and false on a deftype, so
#(and
As for being able to attach metadata, you just have to implement IObj
on your functoids.
--
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 - ple
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
whats wrong with implementing Fn and IMeta?
On Feb 13, 9:35 pm, Ken Wesson wrote:
> As for being able to attach metadata, you just have to implement IObj
> on your functoids.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, sen
On Feb 10, 7:47 pm, Edgar Gonçalves wrote:
> So for future reference, if you come up with the same issue, the solution is
> to compile your gen'ed-classes and delete all the others from the
> war/WEB-INF directory, making sure you have a standalone jar along the
> remaining used jars (a uberjar ma
any serializable java object should be supported. hmmm... i guess that
would work - simply output the object as a byte string and then decode
that.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegrou
On Sun, Feb 13, 2011 at 11:26 PM, Seth wrote:
> whats wrong with implementing Fn and IMeta?
I don't know. But when I checked a normal function's supers I saw IFn,
AFn, and AFunction; and when I checked a vector's I saw only IFn of
those three. I also saw IObj, did a .getMethods on it, and the met
I know that IMeta is used with the (meta) function and with IObj, you
can also implement with-meta. And fn? tests for 'true functions' ,
i.e. only the function created by (fn). Not sure about the rest...
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
not fast, but it works:) any ideas on better code?
;code from
http://www.mail-archive.com/clojure@googlegroups.com/msg19378.html
;;saving objects to strings and going back -slow, but it works
(import (java.io ByteArrayOutputStream ObjectOutputStream
ByteArrayInputStream Objec
or i could have just used base64:) I love leiningen +maven+central
repository!
(import (java.io ByteArrayOutputStream ObjectOutputStream
ByteArrayInputStream ObjectInputStream)
org.apache.commons.codec.binary.Base64)
(defn bytes-to-obj
"convert string to object"
[s]
Thanks a lot.
I'll have to get used to closing all parentheses of a function on a
single line, cause this makes finding the right position when editing
the code afterwards a little harder. Also now I got the clojure mode
for emacs (instead of lisp mode) to get the indentation right.
--
You recei
To turn a signed byte (-128 to 127) into an unsigned one:
(bit-and the-byte 0xff)
The byte (for example 0x80, which is negative) will be extended to an
int (0xff80) and anded with 0x00ff (and you get 0x0080,
which is positive).
The javadoc for the methods of DataInput[1] contain form
39 matches
Mail list logo