I think regex free solution is best for this
(defn last-indexof [s c]
(->> s (filter #(= c %)) count dec)
On Nov 12, 3:36 am, "jongwon.choi" wrote:
> Hi
>
> I'm wondering the best way to express:
>
> (position #\a "abba" :from-end t)
>
> Should I use interop?
>
> (.lastIndexOf "abb
I am trying to run the examples in seesaw.I must not have seeesaw
installed correctly.
any help please
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\>cd cljr
C:\cljr>java -jar c:/clojure-1.3.0.jar c:/cljr/kitchensink.clj
Error: Unable to
Also note that even given all this generality over the Python code - the
earlier Python implementation takes ~300ms and this implementation takes
>900ms on my machine.
Quite a bit slower than ~12ms. Inferring 40 takes even less time of course
- ~8ms.
But really the execution time is just icing on
Excellent point Ambrose ;) And here it is:
(define (subchecko w sl r o n)
(conde
((== sl ())
(fresh (a d)
(domfd a (range 1 100))
(conde
((conso a d r) (plusfd a 1 w)
(conso w r o))
((== r '()) (conso w r o)
((fresh (a b c
I assume the cKanren version can run backwards with a little tweak?
--
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 y
(define (matches n)
(run #f (q)
(fresh (a b c d s1 s2)
(== q `(,a ,b ,c ,d))
(domfd a b c d s1 s2 (range 1 n))
(all-differentfd `(,a ,b ,c ,d))
(== a 1)
(<=fd a b) (<=fd b c) (<=fd c d)
(plusfd a b s1) (plusfd s1 c s2) (plusfd s2 d n)
(checko `
Can you reorder your statements without changing the meaning of your
program? For example you cannot move the placement of the "return"
expression.
David
On Fri, Nov 11, 2011 at 8:09 PM, Jules wrote:
> Here is a new program. Perhaps you would consider this declarative:
>
> def valid(a,b,c,d):
>
Ahhh...excellent, I see why I was blind. =) If you just build your
reduction collection in reverse, then the head of the reduction is
always the one you want to compare with as you traverse the incoming
collection. So you either cons one item or two onto the result, and
when you're all done reve
Since you're given a sorted list of intervals, you don't actually need to
restart the whole merging process from the start after each merge; you can just
replace the last interval in your output with the new, merged interval and
continue from there. So `reduce' is the perfect tool for the job; m
On Nov 8, 12:47 pm, loonster wrote:
> After searching long and hard, there really isn't any good
> documentation for using sqlite3 with clojure 1.3. Any help connecting
> to an existing sqlite3 db and performing selects and updates greatly
> appreciated. Tim
Thanks all. In the end, the foll
I'm having a conceptual problem, thinking functionally, and I was
hoping the fine Clojurians could take a peek.
Boiled down, I need to do a combination of map and reduce on a
collection. My "walker" needs to look at pairs along the collection,
but then sort of "inject" new values and restart when
Here is a new program. Perhaps you would consider this declarative:
def valid(a,b,c,d):
weights = set(w*a+x*b+y*c+z*d for (w,x,y,z) in
product([-1,0,1],repeat=4))
return weights >= set(range(1,41))
ws = [(a,b,c,d) for (a,b,c,d) in product(range(1,41),repeat=4)
if a <= b <=
Are we reading the same cKanren code? I'll give you that the matches
definition is declarative, but then read checko and subchecko. They
are all about (recursive) control flow. Where does the specification
say anything remotely close to the checko and subchecko relations? In
contrast to this, the P
Those are 2 very good links so far. You can always look at the "Clojure
Toolbox" to get an idea of the landscape.
- http://www.clojure-toolbox.com/
But the github link, though, will take you closer to what different people
are working on. It is a good idea though, to step back and try to scrat
> My Python code is much more declarative than the given
> cKanren code in that regard. Just compare:
> http://dosync.posterous.com/another-taste-of-ckanren
I don't think you understand what declarative programming is at its
core. Declarative programming
To borrow from the ever-present wikipedi
In the same way the cKanren version is syntactic sugar around
imperative code. Declarative is not a property of a language, it's a
property of code that says how close to a mathematical specification
the code is. My Python code is much more declarative than the given
cKanren code in that regard. Ju
>I wonder if you can make the cKanren version just as declarative as
>this one (cKanren's purpose being declarative).
I don't think the Python version could be considered declarative. One
of the concepts behind logic
programming (and to some extent declarative programming) is that you
can simply p
Hi
I'm wondering the best way to express:
(position #\a "abba" :from-end t)
Should I use interop?
(.lastIndexOf "abba" (int \a))
Thanks!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@google
On Nov 9, 2:47 pm, Shoeb Bhinderwala
wrote:
> (["a"] ["a" "b"] ["a" "b" "c"] ["a" "b" "c" "d"])
It should be pointed out that this result -- while it may be what you
actually want -- is not "all subsets of" ["a" "b" "c" "d"]. For that
you might want to use combinatorics/subsets:
user=> (C/subset
On Nov 8, 10:08 pm, Aquahappy wrote:
> Hi Jim,
>
> Thanks so much! Using 'def' instead of 'defn' when defining a function
> composed of functions was what I was missing.
>
> I can't believe I spent an hour trying to figure this out -- it seems
> very obvious now. Doh!
>
> :)
Notice that the Scheme
So far its looking like I can't. I will just have to work around it
then. NBD.
Thanks
On Nov 11, 12:02 pm, Chris Perkins wrote:
> It looks like your (:foo d) is a symbol. ((:foo d) 4 5) is trying to look
> itself up as a key in the map you provided, which is 4. Since that's not a
> map, the loo
Here is a Python version (http://pastebin.com/reW5eaCy):
def valid(a,b,c,d):
return set(w*a + x*b + y*c + z*d
for w in [-1,0,1]
for x in [-1,0,1]
for y in [-1,0,1]
for z in [-1,0,1]) > set(range(1,41))
ws = [(a,b,c,d) for a in range(
Go to search.maven.org, and type in jericho-html. That'll take you to some
results pages that will tell you the versions that are available, and also
the correct groupId and artifactId.
Then you add into project.clj the following [groupId/artifactId
"version"]. In this case, [net.htmlparser.j
I want to interface with the Jericho html-parser available from
sourceforge. How do I specify it in project.clj for lein to fetch?
--
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
I just released a new version of doric (https://github.com/joegallo/doric)
-- it's a fun little utility library that you might want to look at if
you're using clojure.pprint/print-table, but want a few more features than
it provides. This version includes support for generating csv, raw text,
It looks like your (:foo d) is a symbol. ((:foo d) 4 5) is trying to look
itself up as a key in the map you provided, which is 4. Since that's not a
map, the lookup fails and it returns the default value you provided: 5.
It's very forgiving that way :)
As for your main question, about how to
If I use pprint and read-string to serialize and deserialize data
w/o function references it works o.k. This is clojure 1.3.
e.g. save something to disk, restart the vm, read it in ok.
user=> (def foo {:a 1 :b 2 :c ["more" "stuff"]})
user=> (def output (java.io.FileWriter. "foo.clj"))
user
Thanks Brian - I will look into it.
On 11 November 2011 15:40, Brian Marick wrote:
>
> On Nov 11, 2011, at 4:48 AM, Colin Yates wrote:
> > Now this works except for the fact I have multiple decorators which work
> on a graph which might be 5 levels deep and looks horrible :).
>
> Have you looked
On Nov 11, 2011, at 4:48 AM, Colin Yates wrote:
> Now this works except for the fact I have multiple decorators which work on a
> graph which might be 5 levels deep and looks horrible :).
Have you looked into clojure.zip?
http://www.exampler.com/blog/2010/09/01/editing-trees-in-clojure-with-clo
You could consider contributing your improvements to the logging library.
On Nov 11, 2011 10:27 AM, "finbeu" wrote:
> Thanks. I think when I tried it (correct me if I'm wrong) it was not
> possible to set the debug level dynamic. For instance I usually have a port
> where I can send messages to (
Thanks. I think when I tried it (correct me if I'm wrong) it was not
possible to set the debug level dynamic. For instance I usually have a port
where I can send messages to (simple UDP datagram packet), the message
string is a map which I read-string and eval and upon that event, I reset
some
On Fri, Nov 11, 2011 at 9:25 AM, finbeu wrote:
> yes, when starting my project, I was looking at the logging library which
> resides (resided) in clojure.contrib and I didn't like it at that point in
> time. I think because it was trying to do too many things at once. If my use
> case can be solve
This is what I get when I run the commands. I have had lleiningen installed
and used it somewhat.
I get the "classpath" error and I don't understand ?
Thanks for your help
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\Users\jim.jim-PC>c
yes, when starting my project, I was looking at the logging library which
resides (resided) in clojure.contrib and I didn't like it at that point in
time. I think because it was trying to do too many things at once. If my
use case can be solved with some small java wrappers, I try to do it on my
On Fri, Nov 11, 2011 at 8:53 AM, finbeu wrote:
> no, not yet. I stick with my own simple logging ns which works nice so far.
> Just have to fix this ...)
I just wondered whether using a well-maintained "standard" library
might be an easier path than rolling your own...
> (but I use clojure.java.
Yes! That's it. With pr-str it works. Thx!!
--
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 uns
Hi Sean
no, not yet. I stick with my own simple logging ns which works nice so far.
Just have to fix this ...)
(but I use clojure.java.jdbc with Sybase ASE 15.0.3. I hope I will find
some time soon to contribute some testcases.)
Finn
--
You received this message because you are subscribed to
Hi,
what happens is probable that the logger tries to turn the lazy seq object
itself into a string. Try calling pr-str on the seq before passing it to
debug: (debug (pr-str your-seq-object)).
Sincerely
Meikel
--
You received this message because you are subscribed to the Google
Groups "Cloju
Have you tried clojure.tools.logging to see whether you get the same behavior?
On Fri, Nov 11, 2011 at 8:15 AM, finbeu wrote:
> Hello,
> I'm using log4j and have some a simple wrappers in clojure that work well so
> far.
> Actually, I do
> (def *logger* (Logger/getRootLogger))
>
> Then I set logl
Hello,
I'm using log4j and have some a simple wrappers in clojure that work well
so far.
Actually, I do
(def *logger* (Logger/getRootLogger))
Then I set loglevel, appenders, layout and so on.
I have a function
(defn debug [msg]
(.debug *logger* msg)
This works nice as long as I do not tr
On Nov 11, 5:29 am, jayvandal wrote:
> I tried this command but can't find how to execute it.
> $ lein run -m gaidica.core
> What folder do I execute this ? (Vista windows )
> Probably simple but it's difficult for me
> Thanks
>
> # gaidica
>
> Example Seesaw application. Display weather data
Oops - clicked wrong button (why doesn't gmail have paredit!) - sorry...
(defn transform [graphs]
(let [
;; map of {:id customer}
customers (load-customers-by-id graphs)
]
(defn resolve-customer [g] (assoc g :customer ((:customer g) customers
(defn switch
Hi all,
What is the idiomatic way to decorate a nested graph with multiple
decorators? Let me explain:
I have a list of graphs:
[
{ :id 1
propertyA: {:customer 1 :name whatever :date (Date.)}
propertyB: {:customer 1 :created (Date.) :someOtherProperty 13}
}
]
After creating this graph (an
43 matches
Mail list logo