Hello,
IM busy with 4Clojure and I have now two challenges which I think can be
solved the same way.
On a list I first have to find the last item of a list without using last
and after that I have to do the same for a nth item and im not allowed to
use nth.
Now I can convert the list to a
Your intuition that this can be done through recursion or a loop is correct
(the latter being a more specialised version of the former).
When dealing with recursion, it often helps to consider the base case, i.e.
where the recursion stops. Typically this is when you get to zero or one
elements.
Roelof Wobben rwob...@hotmail.com writes:
Could a recurvice way or a loop do the trick.
Yes.
And how do I then take the right value.
For nth, you need a counter that you can increment in each recursion
step. For last, you return the first element of the list whose rest is
the empty list.
Op woensdag 30 april 2014 08:21:40 UTC+2 schreef James Reeves:
Your intuition that this can be done through recursion or a loop is
correct (the latter being a more specialised version of the former).
When dealing with recursion, it often helps to consider the base case,
i.e. where the
Op woensdag 30 april 2014 08:22:07 UTC+2 schreef Tassilo Horn:
Roelof Wobben rwo...@hotmail.com javascript: writes:
Could a recurvice way or a loop do the trick.
Yes.
And how do I then take the right value.
For nth, you need a counter that you can increment in each recursion
Imagine you're reading through some documentation and you notice a
problem. Maybe a typo, or something out of date, or something that's
confusing that you could explain better. In one scenario there's a git
clone link in the sidebar to a repository that contains a bunch of
markdown files. In
Op woensdag 30 april 2014 08:50:22 UTC+2 schreef Roelof Wobben:
Op woensdag 30 april 2014 08:22:07 UTC+2 schreef Tassilo Horn:
Roelof Wobben rwo...@hotmail.com writes:
Could a recurvice way or a loop do the trick.
Yes.
And how do I then take the right value.
For nth, you need
After posting this last week I decided to go down the explicit map route,
and I'm already really glad I did. Amongst other things, it has allowed me
to have two similar calls easily share their common options and merge in
the differences. I'm generally a fan of maintaining fairly minimal APIs, I
On 30 April 2014 07:49, Roelof Wobben rwob...@hotmail.com wrote:
Op woensdag 30 april 2014 08:21:40 UTC+2 schreef James Reeves:
1. How do you find the last element of a seq with exactly one element?
the last and the first element are the same
Right. So to formalise it:
(defn
Thanks James, that's a useful version to experiment with :)
On Wed, Apr 30, 2014 at 12:04 AM, Colin Fleming colin.mailingl...@gmail.com
wrote:
After posting this last week I decided to go down the explicit map route,
and I'm already really glad I did. Amongst other things, it has allowed me
I thought that once defined clojure vars are immutable and retain their
values. However, I
accidentally bumped into a situation where I observe the same var in two
different states.
Here's how to reproduce:
lein new app vartest
Add the following files to the test folder:
-
(ns
When a namespace is reloaded any vars defined in it are re-evaluated. In
your case it would seem that some quirk of the Leiningen test architecture
is leading to vartest.test-data being loaded twice.
In general namespaces should be robust when it comes to being reloaded.
Clojure provides a macro,
Roelof Wobben rwob...@hotmail.com writes:
For nth, you need a counter that you can increment in each recursion
step. For last, you return the first element of the list whose rest
is the empty list.
Thanks, and if I use cons (item, list) then item is the value I
want. I only have to print
my two cents:
The extra readability to users when using keyword args also comes from the
fact that a function's options are explicit in its signature. So during
development, instead of having to look them up in the docs or in the code,
my emacs mini-buffer simply shows them to me. Although I
Op woensdag 30 april 2014 09:58:26 UTC+2 schreef James Reeves:
On 30 April 2014 07:49, Roelof Wobben rwo...@hotmail.com javascript:wrote:
Op woensdag 30 april 2014 08:21:40 UTC+2 schreef James Reeves:
1. How do you find the last element of a seq with exactly one element?
the last
Op woensdag 30 april 2014 09:58:26 UTC+2 schreef James Reeves:
On 30 April 2014 07:49, Roelof Wobben rwo...@hotmail.com javascript:wrote:
Op woensdag 30 april 2014 08:21:40 UTC+2 schreef James Reeves:
1. How do you find the last element of a seq with exactly one element?
the last
Yes, one would hope so. Then again, they've been using Pedestal-App for
their projects as well... :-)
Anyway, pedestal seems the way to go. After all, I could also see myself
replacing it with the latest and greatest routing library without much
hassle, should it once be deprecated.
On
Hoplon looks really interesting. It’s just that I don’t want to build a
single page application, so it’s kind of moot to consider it, I guess.
I was planning to have a lot of server rendered pages in the app, not least
to make the content accessible for search engine bots. For the dynamic UI
But that's only true for the variables which are explicitly destructured in
the function definition, which in my experience many are not - they're
often later picked out of an :as args argument, perhaps dependent on a
combination of the parameters which are explicitly destructured. Seesaw
never
And thinking about it (after pressing send, of course), you'd get the
same benefit from destructuring an explicit map in the function parameter
anyway, wouldn't you?
On 30 April 2014 22:11, Colin Fleming colin.mailingl...@gmail.com wrote:
But that's only true for the variables which are
On 30 April 2014 10:41, Roelof Wobben rwob...@hotmail.com wrote:
Op woensdag 30 april 2014 09:58:26 UTC+2 schreef James Reeves:
Unlike vectors, seqs are simple structures and don't know their own
length.
You can count seqs, but this involves iterating through every element in
turn. If
Hi Richard
Sorry for the delay. We'll check that out!
Having said that, my inclination would be to avoid the compile step if we
can and just run on top of the leiningen project (e.e. analogous to ruby
apps).
Putting Engine Yard aside, it raises an interesting question so I am
wondering what
Op woensdag 30 april 2014 12:14:39 UTC+2 schreef James Reeves:
On 30 April 2014 10:41, Roelof Wobben rwo...@hotmail.com javascript:wrote:
Op woensdag 30 april 2014 09:58:26 UTC+2 schreef James Reeves:
Unlike vectors, seqs are simple structures and don't know their own
length.
You
On 30 April 2014 11:41, Roelof Wobben rwob...@hotmail.com wrote:
Op woensdag 30 april 2014 12:14:39 UTC+2 schreef James Reeves:
Consider how you might add a counter to the loop. You'll want to
increment the counter, then stop when it reaches the desired number.
So without checking it so
Phil Hagelberg p...@hagelb.org writes:
On Saturday, April 26, 2014 9:21:26 PM UTC-7, Mars0i wrote:
I like the general idea of the Valentin's proposal, but I don't
understand every bit of it. It sounds complicated. Personally, I'd
rather see something that's relatively simple, and good
On 30/04/14 04:25, Paulo Suzart wrote:
If anyone knows any other sliding window impl please share.
Riemann seems to have one:
http://riemann.io/howto.html#group-events-in-time
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group,
Hi, I wanted to get started with clojure.test.check (formerly simple-check)
and I am new to property based testing.
I plucked clojure.core/group-by for no particular reason as a function to
test.
I started by stating some properties i think should hold:
;; 1. applying the grouping key
This is getting to the point where it seems to make sense as a wiki
page like http://dev.clojure.org/display/community/Clojure+User+Groups
Maybe http://dev.clojure.org/display/community/Clojure+Office+Hours ?
On Tue, Apr 29, 2014 at 5:53 PM, Lynn Grogan l...@thinkrelevance.com wrote:
This is
We've had lots of luck with Narrator: https://github.com/ztellman/narrator
It's got loads of powerful features, including realtime batch mode,
integration with core.async and lamina, windows, functions, and recursive
analyses.
On Tuesday, April 29, 2014 10:25:39 PM UTC-4, Paulo Suzart wrote:
Hi all,
I've released a Clojure web application. It includes a front-end using
DataScript and React.js in ClojureScript.
More details here:
http://thegeez.net/2014/04/30/datascript_clojure_web_app.html
The code is on github: https://github.com/thegeez/clj-crud
Demo on heroku:
Tim, I am in full support of the approach to documentation that you
describe, for individuals and organizations that feel that it best supports
their needs. It's a good approach. I don't favor requiring an entire
programming community to follow it. That's too much of an imposition. I
do
We used kwargs for options extensively in Immutant 1.x, and we're moving to
explicit maps for Immutant 2.x, for the reasons cited above.
It's not obvious to me why the bad release-sharks example on the coding
standards page [1] is bad. Why should the optional config be the least
variance
Ow, exactly what I was looking for. Thanks a lot
On 30 Apr 2014 10:26, dgrnbrg dsg123456...@gmail.com wrote:
We've had lots of luck with Narrator: https://github.com/ztellman/narrator
It's got loads of powerful features, including realtime batch mode,
integration with core.async and lamina,
Maybe they want config in the least variance argument so it can be
partial'ed?
On Wed, Apr 30, 2014 at 10:03 AM, Jim Crossley j...@crossleys.org wrote:
We used kwargs for options extensively in Immutant 1.x, and we're moving
to explicit maps for Immutant 2.x, for the reasons cited above.
On 4 clojure there it this exercise:
(= (__ (sort (rest (reverse [2 5 4 1 3 6]
(- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))
5)
if I understand it right this is happen
reverse[ 2 5 4 1 3 6] gives [ 6 3 1 4 5 2 ]
Then rest [ 6 3 1 4 5 2] gives [ 3 1 4 5 2]
Sort this and you get [ 1
Valentin, et al,
I'm a little late to the thread here, but I'm the author of lein-sphinx
which you mentioned in your (well thought out) post so I thought I'd weigh
in here.
I agree with a lot of what you wrote in your proposal, and for many
projects (not all of them, but many) there is an
I would like to try the JTransforms Java FFT library from Clojure:
https://sites.google.com/site/piotrwendykier/software/jtransforms
I created a new folder went to that folder in a console and typed
lein try net.sourceforge.jtransforms/jtransforms 2.4.0
lein try retrieved some jars and poms
You have to replace the underscore with a function. The value of (= (_ [1 2
3 4 5]) 5) must be true. So the value of (_ [1 2 3 4 5]) must be 5. So the
function you are looking for will have to return the last element of the
array.
On Wednesday, April 30, 2014 5:28:26 PM UTC+2, Roelof Wobben
Thank you very much. This definitely helps.
-Kranthi
On Sat, Apr 26, 2014 at 9:17 PM, Armando Blancas abm221...@gmail.comwrote:
I haven't touched this project in a while, but it might be useful.
https://github.com/blancas/tinypost
This file has the relevant interop code:
It looks like a quiz. Which function should stand in place of underscores
to give 5 in result?
On Wed, Apr 30, 2014 at 7:28 PM, Roelof Wobben rwob...@hotmail.com wrote:
On 4 clojure there it this exercise:
(= (__ (sort (rest (reverse [2 5 4 1 3 6]
(- [2 5 4 1 3 6] (reverse) (rest)
Java libraries are handled differently to native Clojure libraries. You can
either enter the full class with packages, such as:
(java.util.UUID/randomUUID)
Or you can use import to access the class without the package:
(import 'java.util.UUID)
(UUID/randomUUID)
To check you have
Hi, Alan.
'require' is only for clojure libs. For Java packages, use 'import':
user= (import '[edu.emory.mathcs.jtransforms.fft DoubleFFT_1D])
edu.emory.mathcs.jtransforms.fft.DoubleFFT_1D
user= (def da (double-array (range 0 10 0.01)))
#'user/da
user= (def fft (DoubleFFT_1D. (count da)))
These two forms are equivalent:
(__ (sort (rest (reverse [2 5 4 1 3 6]
(- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))
The - macro turns the second form into the first. You can see this by
running macroexpand-all:
(require '[clojure.walk :refer [macroexpand-all]])
Op woensdag 30 april 2014 18:46:36 UTC+2 schreef James Reeves:
These two forms are equivalent:
(__ (sort (rest (reverse [2 5 4 1 3 6]
(- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))
The - macro turns the second form into the first. You can see this by
running
Op woensdag 30 april 2014 19:12:24 UTC+2 schreef James Reeves:
The 5 is just the last part of the equality statement. This might be
easier to see by adding in a let:
(let [x (__ (sort (rest (reverse [2 5 4 1 3 6]
y (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))]
(= x y 5))
The 5 is just the last part of the equality statement. This might be easier
to see by adding in a let:
(let [x (__ (sort (rest (reverse [2 5 4 1 3 6]
y (- [2 5 4 1 3 6] (reverse) (rest) (sort) (__))]
(= x y 5))
- James
On 30 April 2014 18:09, Roelof Wobben rwob...@hotmail.com
The __ needs to be replaced with a function. So essentially it boils down
to:
(= (__ [1 2 3 4 5]) 5)
What function when called with [1 2 3 4 5] returns 5?
- James
On 30 April 2014 18:18, Roelof Wobben rwob...@hotmail.com wrote:
Op woensdag 30 april 2014 19:12:24 UTC+2 schreef James
Op woensdag 30 april 2014 19:46:41 UTC+2 schreef James Reeves:
The __ needs to be replaced with a function. So essentially it boils down
to:
(= (__ [1 2 3 4 5]) 5)
What function when called with [1 2 3 4 5] returns 5?
- James
Thats a easy one . That is last.
But what I try to
On Tue, Apr 29, 2014 at 7:44 PM, Phil Hagelberg p...@hagelb.org wrote:
On Saturday, April 26, 2014 9:21:26 PM UTC-7, Mars0i wrote:
I like the general idea of the Valentin's proposal, but I don't
understand every bit of it. It sounds complicated. Personally, I'd
rather see something
Granted, but the word bad seems harsh without any explanation, especially
if the common usage is to pass an empty map.
On Wed, Apr 30, 2014 at 11:18 AM, Alex Robbins
alexander.j.robb...@gmail.com wrote:
Maybe they want config in the least variance argument so it can be
partial'ed?
On Wed,
On Wednesday, 30 April 2014 19:03:24 UTC+1, Gregg Reynolds wrote:
The one thing that I think would be genuinely useful and developer
friendly with respect to Clojure is a means of making type signatures
explicit. Clojure may be dynamically typed, but everything has an intended
type, and
Hi,
Is it possible to have a browser based repl for clojurescript with
counterclockwise? I tried to set up one as described on the clojurescript
site, but my impression was that ccw is not able to send forms for
evaluation.
Cheers,
Razvan
--
You received this message because you are
packthread
Threading macros for working with globs of state.
https://github.com/maitria/packthread/blob/master/README.md#whyWhy?
Many descriptions about state in Clojure fit into the following form:
State is hard to reason about, and so we use pure functions in Clojure. But
then we have a
The only hard parts about property based testing are the properties and the
generators. ;)
On Wednesday, April 30, 2014 6:38:19 AM UTC-5, henry w wrote:
Hi, I wanted to get started with clojure.test.check (formerly
simple-check) and I am new to property based testing.
I plucked
As an aside to the discussion at hand, what papers/books/online
articles are good to read to learn about how to come up with good
properties and generators?
On Wed, Apr 30, 2014 at 3:36 PM, Alex Miller a...@puredanger.com wrote:
The only hard parts about property based testing are the properties
Hi all,
I'm having a weird state problem with
Componenthttps://github.com/stuartsierra/component.
Let's say I have a system component, like in fig.1. Starting / stopping and
loading state is fine.
However, let's say I have 2 other components (:updater , :reader) that use
component :a. This is the
Humm. Actually narretor flushes all messages. Still not what I'm looking
for somethiing like this:
http://docs.oracle.com/cd/E13157_01/wlevs/docs30/epl_guide/overview.html(see
the images).
Thanks anyway
On 30 April 2014 12:15, Paulo Suzart paulosuz...@gmail.com wrote:
Ow, exactly what I was
On Apr 30, 2014, at 11:03 AM, Gregg Reynolds d...@mobileink.com wrote:
Controversial: literate programming is a bad, bad, bad idea. There is a
reason it has never caught on.
I was going to stay out of this discussion but... I agree with Gregg here. All
that prose just gets in the way and
On Apr 29, 2014, at 9:42 PM, Atamert Ölçgen mu...@muhuk.com wrote:
Since I don't use emacs, I would probably have found the former easier.
I don't think Emacs has anything to do with this, even tho' Phil used the
example of org-mode etc. I agree that if working on the code - and keeping the
On Apr 30, 2014, at 8:03 AM, Jim Crossley j...@crossleys.org wrote:
It's not obvious to me why the bad release-sharks example on the coding
standards page [1] is bad. Why should the optional config be the least
variance argument?
I had to look up laudable, btw. It's one of those good words
I think they're unaware of the change, as it resulted from a recent
conversation on IRC that same day, where sentiment indicated that kwargs
are generally more trouble than they're worth and there's still confusion
around it.
What started it: the example of keys-destructuring on a list in a let
Since you already like clojurewerkz EEP, why not just add a time-sliding
window to it?
--Leif
On Wednesday, April 30, 2014 5:13:42 PM UTC-4, Paulo Suzart wrote:
Humm. Actually narretor flushes all messages. Still not what I'm looking
for somethiing like this:
Some good links here:
https://github.com/clojure/test.check
But related communities like QuickCheck, ScalaCheck, etc are probably good
places to look.
Someone should start making something great for test.check on the wiki:
https://github.com/clojure/test.check
Hint hint hint!
On Wednesday,
Sorry I have been late to react to all this, since I'm the one who started
it all.
First, *as a side note* : I have nothing against docstrings. I acknowledge
their benefits, I think we should keep using them and I enjoy them every
day like all of you. My point was just that they were not
One approach you can use is write the generators in such a way that they
generate the final answer group-by should return, then you write code
which does the inverse to group by and then you check the group by answer
is equal to the originally generated solution.
On Wednesday, April 30, 2014
Wasn't Pedestal-app placed on hiatus? What is the current status of that?
On Tuesday, April 29, 2014 10:35:25 AM UTC-5, Mike Haney wrote:
Pedestal was developed by Cognitect and I would assume they use it on many
of their consulting projects. Since future support appears be a major
Here's the thing I can't stand about keyword args:
Let's start off with a simple function that looks for keys x and y, and if
either is missing,
replaces the value with 1 or 2 respectively.
(defn f [ {:keys [x y] :or {x 1 y 2}}]
[x y])
= (f :x 10)
[10 2]
So far, so good.
Now, let's do an
Thank you. It's my honour that nginx-clojure will being used possibly.
As you said, coroutine based Java socket implementation can simplify
asynchronous event model.
We just write synchronous style code about java socket API and get the
non-blocking and event driven executing on nginx.
On
Pedestal-app is pretty much dead, but pedestal (service) is alive and well,
and that is what I was talking about.
I know some people were upset when pedestal-app was put on hiatus, but I look
at it a different way. Libraries like react (and its clojurescript
counterparts) are changing the
Unless I'm missing something subtle, all of your points would hold if you
removed the in your argument vector to turn your kwargs into an explicit
map, wouldn't they? One advantage is you'd be able to (apply f [m]), but
I'm not sure the :or logic would be any less troublesome.
On Wed, Apr 30,
I think it would because in that case you'd just pass your arg map straight
through rather than having to reconstruct it. So if you weren't passed :y
in g (in Mark's example), g wouldn't pass it on to f. By forcing the
reconstruction of the map from explicit args, you're forced to use the
value
Hi everyone,
After the very interesting keyword argument debate, I have another question
about API design. Specifically I'm interested in suggestions about
parameter order. The new API guidelines, which have changed very recently
to favour maps over keyword args, also changed to include a
Wow
Thank you so much for this - I played with the demo on Heroku - and this is a
great starter skeleton for someone like myself who wants to build a web app.
Please keep up the good work and I like your roadmap tasks in your todo list -
they are all relevant and useful for someone like
Hi,I watched @rkneufeld 's webcast on pedestal recently and it was really
nice.I was wondering how I could go about deploying a pedestal based app on
GAE. I'd appreciate any pointers very much.Regards,Kashyap
--
You received this message because you are subscribed to the Google
Groups Clojure
Hi, Colin.
I don't use 'partial' that much either, since anonymous functions are so
easy to create. A fn also has the advantage (to my mind) of making it
clear what arity the old and new fns have. 'Partial' turns a multi-arity
fn into another multi-arity fn, which I personally think is very
Oh, right. (f m) instead of (apply f [m]). Duh.
On Wed, Apr 30, 2014 at 11:15 PM, Colin Fleming colin.mailingl...@gmail.com
wrote:
I think it would because in that case you'd just pass your arg map
straight through rather than having to reconstruct it. So if you weren't
passed :y in g (in
I've been programming a bit in Clojure, and in my opinion it's like making
Java programs without typing long Java because of it running on the JVM.
However, I wanna be able to convert my Clojure code to Java code. I know
Leiningen can do that, but I am really clueless at this point, and I
Hello everyone,
In Clojure 1.6:
user (doseq [:let [a 1] b '(1 2 3)] (println a b))
1 1
1 2
1 3
nil
user (for [:let [a 1] b '(1 2 3)] (println a b))
IllegalStateException Can't pop empty vector
clojure.lang.PersistentVector.pop (PersistentVector.java:381)
user
Is this expected behavior? a
At least a few people consider it a bug, and two of them created a ticket,
the first of which was declined as not a bug. That is some evidence that
it is considered not a bug:
http://dev.clojure.org/jira/browse/CLJ-1316
http://dev.clojure.org/jira/browse/CLJ-207
Andy
On Wed, Apr 30,
Leiningen can convert Clojure source code to Java .class files (compiled
Java byte code, not Java source code), with the help of the Clojure
compiler.
I don't know of a way Leiningen can convert that to Java source code,
unless there is some feature of Leiningen I haven't learned about yet, or
You could also check https://github.com/galdolber/clojure-objc, which uses
a modified Clojure compiler to output Java source instead of bytecode. It's
been subsequently modified to work with ObjC, I'm not sure whether that
affects its ability to execute the program as Java or not.
On 1 May 2014
81 matches
Mail list logo