needs a reader syntax for floats

2012-08-14 Thread Matthew Kennedy
While doing image processing in Clojure recently it occured to me that it 
would be handy to have a specifier suffix for distinguishing between 
doubles and floats as libraries in this domain often use single precision 
floats instead of double precision (or mixtures of both). 

My code frequently contains things like 

[(float 0.12) (float 0.33) (float 0.56)]. 

e.g. image convolution kernels etc. I'd much rather it look like this:

[0.12f 0.33f 0.56f]

As far as I can tell there's no way to do this with user code. I think it 
would have to be done within the Clojure runtime by adjusting 
ListReader.java to change the floating point reader regex and switching on 
an suffix character.

The current behavior is:

  123.32M - BigDecimal
  123.32 - double

I propose:

  123.32M - BigDecimal
  123.32 - double
  123.32f - float
  123.32d - double

I already have a prototype which implements the literal syntax above. Is 
this worthwhile pushing this feature for inclusion in Clojure itself? What 
kind of issues might I be overlooking? About all I can think of is the 
printer needs to print the d or f when *print-readably* is non-nil.

Matt

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Ideas for interactive tasks

2012-08-14 Thread dmirylenka
It's really great that you are going to teach Clojure at BSU.

I have no clue about teaching, but my impression is that back in my days, 
we didn't learn much about how to write good code.
Maybe things were different in 'informatics', but in 'applied mathematics', 
for instance, we only had exposure to imperative programming. If this is 
still the case, I think, your course could get students familiar with the 
concepts and benefits of FP (immutability, referential transparency, etc.). 
Then they could learn more specific things like persistent data structures, 
multimethods, macros, agents, etc.. I would probably try to emphasize the 
advantages of certain features of Clojure and FP in general, when it is 
appropriate to use them and how.

As for the interactive tasks, I think, it's a good idea, as they are fun.
My only note so far is that they seem to require quite some effort 
unrelated to learning Clojure, but it may be what you intended (would be 
nice seing your course program).
For instance, in 'artillery' task, the time it took to code up the solution 
was infinitesimal, compared to the time I spent building the model and 
recalling how to solve trigonometric and quadratic equations :). But seing 
the plain fall was rewarding...

One task I remember form my courses was to program a trolley that moves 
parts between the machines of a production line (Each machine has an input 
and output queue with limited capacities, and a distinct processing time). 
This can also be extended for concurrency task, if you introduce two 
trolleys, etc.
Another thought about concurrency - let them program the 'dining 
philosophers'.
In addition, the idea of writing game bots can be exploited further: e.g. 
what about a tetris bot?

I'm very excited about your intent to teach Clojure at BSU. I would be glad 
to stay in touch for further discussions.

Daniil

On Monday, August 13, 2012 9:17:26 PM UTC+2, Nikita Beloglazov wrote:

 Daniil, yes it is
 Do you have some suggestions about tasks or teaching at the BSU in 
 generally? :)

 Nikita


 On Mon, Aug 13, 2012 at 9:00 PM, dmirylenka daniilm...@gmail.comjavascript:
  wrote:

 Wow, too bad I already graduated :)

 ФПМИ?


 On Thursday, August 9, 2012 5:28:54 PM UTC+2, Nikita Beloglazov wrote:

 Thank you, Jim. This is Belarusian State University.

 On Thu, Aug 9, 2012 at 6:23 PM, Jim - FooBar(); jimpi...@gmail.comwrote:

 On 09/08/12 16:21, Nikita Beloglazov wrote:

 I'm going to organize little clojure course at my university this year.


 this is amazing! seriously, bravo! what university is this?

 Jim


 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com

 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@**googlegrou**ps.com

 For more options, visit this group at
 http://groups.google.com/**group**/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en


  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Overtone - Live @ Arnolfini

2012-08-14 Thread charlie
Exciting times indeed!

On Wed, Aug 8, 2012 at 10:46 AM, lambdatronic gwjoh...@uvm.edu wrote:

 Eppccc!!


 On Friday, August 3, 2012 6:47:50 AM UTC-4, Sam Aaron wrote:

 Hi everyone,

 for those interested, I just put up a screencast of a performance I did
 with Overtone on Friday the 27th of July at the Arnolfini art gallery in
 Bristol, UK:

 https://vimeo.com/46867490

 The screen resolution is a little odd as I mirrored my display to that of
 the projector. Also, the sound starts cutting out for about 20s in the
 middle due to some SuperCollider memory issues I managed to run into - it
 was a hairy moment, but I managed to recover.

 It was a lot of fun projecting Clojure code on a massive screen to an
 audience of interesting art enthusiasts :-)

 Also, the code I used to do the performance is here:

 http://github.com/samaaron/**arnold http://github.com/samaaron/arnold

 Enjoy!

 Sam

 ---
 http://sam.aaron.name


  --
 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 unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Question about sets

2012-08-14 Thread Gary Trakhman
+1

On Tuesday, August 7, 2012 3:20:44 AM UTC-4, abp wrote:

 I use literals for collection-construction from arbitrary values too. Just 
 haven't run into that issue.

 So, please:

 Put hash maps and hash sets back to the way they were -- they worked 
 perfectly fine.  Use the duplicate key check in ArrayMap to make ArrayMaps 
 behave like all the other maps, i.e., last instance of a key wins.

  



-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: ANN lein-expectations 0.0.7

2012-08-14 Thread semperos
With testing frameworks, there's nothing like trying all of them with a 
medium-sized code base. I use both clojure.test and Midje for 
clj-webdriver, but have recently used (and enjoyed) Expectations to test a 
parser/code-generator.

Midje is the most batteries-included of the three and provides more 
facilities for top-down testing.

On Thursday, August 9, 2012 4:20:49 AM UTC-4, Jay Fields wrote:

 If you like Midje you should probably stick with it. The two libraries 
 were designed with very different goals in mind. Midje is much more 
 polished and targeted adoption early on. expectations was created for 
 testing the application I was working on, made available on github, but 
 never really promoted. If it suits your testing style, you should love it. 
 If not, you'll likely hate it - it's very opinionated. 

 Check out the github page and look at the success examples that are 
 linked. That will cost you less than 5 minutes, and should give you all the 
 information you need to decide which you prefer. 

 Cheers, Jay

 Sent from my iPhone

 On Aug 8, 2012, at 9:28 PM, keeds ake...@gmail.com javascript: wrote:

 Silly question but how is Expectations better or different from Midje?
 I'm just starting out with Midje and was just wondering?

 Thanks,
 Andrew

 On Monday, 6 August 2012 19:43:18 UTC+1, Sean Corfield wrote:

 lein-expectations - the plugin for running Jay Fields' awesome 
 Expectations testing library - has been updated for Leiningen 2.0. 

 If you are using Leiningen 1.x, continue to use lein-expectations 0.0.5. 

 If you are on Leiningen 2.x, you should use lein-expectations 0.0.7 so 
 that exit on test failure is handled correctly. 

 0.0.6 added a partial fix for exit codes in Leiningen 2.0 but it 
 didn't work properly with with-profile. After discussions with Phil 
 H about exit status codes, the logic was changed / simplified for the 
 0.0.7 release. 
 -- 
 Sean A Corfield -- (904) 302-SEAN 
 An Architect's View -- http://corfield.org/ 
 World Singles, LLC. -- http://worldsingles.com/ 

 Perfection is the enemy of the good. 
 -- Gustave Flaubert, French realist novelist (1821-1880) 

  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com javascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en



-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Question about sets

2012-08-14 Thread Herwig Hochleitner
I agree that the current throw-on-duplicates behavior is broken, because it
renders literals with variable keys useless.

 1. Simplicity is partially about having orthogonal primitives. A
duplicate-removing collection factory cannot be sensibly used to implement
a throw-on-duplicates collection factory, nor vice versa, so both seem
equally primitive to me.

Yes, but duplicate-removing is far more common. Also it's far more useful
in terms of runtime behavior. Looking at the original thread, the array-map
constructor should have been fixed, if anything.

The part where throw-on-dupes has value, are configuration maps, which
don't tend to have embedded variables.

So my suggestion is:

- Let the reader do duplicate checking
- If people feel the need, make separate constructor with dupes check
- Have our cake and eat it too

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

ANN: core.cache v0.6.2

2012-08-14 Thread Fogus


core.cache v0.6.2 Release Notes
===

Source code and README at https://github.com/clojure/core.cache

Wiki (in progress) at https://github.com/clojure/core.cache/wiki

core.cache is a Clojure contrib library providing the following features:

Overview



* An underlying `CacheProtocol` used as the base abstraction for implementing 
new synchronous caches

* A `defcache` macro for hooking your `CacheProtocol` implementations into the 
Clojure associative data capabilities.

* Immutable implementations of some basic caching strategies
  - First-in-first-out (FIFOCache)
  - Least-recently-used (LRUCache)
  - Least-used (LUCache)
  - Time-to-live (TTLCache)
  - Soft-Reference cache (SoftCache)
  - Naive cache (BasicCache)

* Implementation of an efficient buffer replacement policy based on the *low 
inter-reference recency set* algorithm (LIRSCache) described in the 
[LIRS](http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.116.2184) paper

* Factory functions for each existing cache type

Quick example

-


(require '[clojure.core.cache :as cache])

(def C (cache/fifo-cache-factory {:a 1, :b 2})

(if (cache/has? C :c)
  (cache/hit C :c)
  (cache/miss C :c 42))

;= {:a 1, :b 2, :c 42}

(cache/evict C :b)

;= {:a 1}

Absorb
--

You can use core.cache in your 
[Leiningen](https://github.com/technomancy/leiningen) and 
[Cake](https://github.com/flatland/cake) projects with the following 
`:dependencies` directive in your `project.clj` file:

[org.clojure/core.cache 0.6.2]

For Maven-driven projects, use the following slice of XML in your `pom.xml`'s 
`dependencies` section:

dependency
  groupIdorg.clojure/groupId
  artifactIdcore.cache/artifactId
  version0.6.2/version
/dependency


Changes from v0.6.1
---

The v0.6.2 version of core.cache contains the following changes:

* Removed reflection warnings.

* Bug fix for LRU, LU and TTL caches disabling the eviction of duplicate keys 
prior to a threshold less than three.

* FIFOCache respects threshold prior to applying its eviction policy.


-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

[ANN]: clj-http 0.5.3 released

2012-08-14 Thread Lee Hinman
Hi all,
I'm pleased to announce the 0.5.3 release of clj-http. clj-http is an
idiomatic clojure http client wrapping the apache client (like ring in
reverse). You should be able to use it from Clojars[1] using leiningen
with the following:

[clj-http 0.5.3]

Since I have not announced releases of clj-http since 0.3.2 (I hate
writing release emails), here are the new features that have been added
since 0.3.2:

- add support for :digest-auth (digest-type authentication)
- add request timing middleware to add :request-time key in response
- send cookie-store cookies with a request automatically
- standardize on lower-case headers for HTTP requests (ring-spec)
- add chunked encoding support (:length no longer required along with
input stream body)
- fix clojure 1.3's exception wrapping for some exceptions
- support http.nonProxyHosts property
- change body decompression to be optional, if desired
- add ability to specify a low-level callback for debugging
- add ability to specify the keystore type
- add ability to add pluggable output coercion (multimethod)
- support custom x509 keystore/trust-stores
- fixed an issue where multiple link headers would cause an exception to
be thrown
- add :debug-body that adds plaintext body information to the :debug output
- add support for :oauth-token authentication
- add ability to save the apache HTTP object when :save-request? is true
- support additional options/delete/copy/move/patch HTTP methods
- add support for 'Link' header
- add ability to specify your own retry-handler for IOExceptions
- change wrap-redirects to redirect according to the RFC and add the
:force-redirects option to be more browser-like
- add support for nested param maps
- add support for cookie stores
- add utility methods to retrieve cookies as a map from the cookie store
- set the default maximum number of redirects to 20
- Cheshire will no longer interfere with clj-json
- make Cheshire an optional dependency, only for {:as :json} and json
form-params
- add status functions into the clj-http.client namespace
- add the ability to specify {:as :clojure} to get back a clojure
datastructure, or {:as :auto} with content-type=application/clojure
- support json-encoded form params
- allow :form-params on PUT requests
- add the :throw-entire-message? option to include resp in Exception message
- add ability to redirect to relative paths

And a very large number of bug fixes.

Please give it a try and open any issues on the github repo[2] that you
find. Check out the readme for the full information and usage and the
changelog[3] for a detailed list of changes.

thanks,
Lee Hinman

[1]: http://clojars.org/clj-http
[2]: https://github.com/dakrone/clj-http
[3]: https://github.com/dakrone/clj-http/blob/master/changelog.org

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: needs a reader syntax for floats

2012-08-14 Thread Sean Corfield
On Mon, Aug 13, 2012 at 11:14 PM, Matthew Kennedy burnsid...@gmail.com wrote:
 [(float 0.12) (float 0.33) (float 0.56)].

That's a sequence of Float objects not a float[], just FYI.

 As far as I can tell there's no way to do this with user code. I think it
 would have to be done within the Clojure runtime by adjusting
 ListReader.java to change the floating point reader regex and switching on
 an suffix character.

Could you use the extensible reader literal approach? I know the
syntax wouldn't be quite as clean, but if you genuinely need float[]
as well as float values, that might be more convenient in the long
run.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: needs a reader syntax for floats

2012-08-14 Thread Matthew Kennedy

On Tuesday, August 14, 2012 3:33:03 PM UTC-5, Sean Corfield wrote:


 Could you use the extensible reader literal approach? I know the 
 syntax wouldn't be quite as clean, but if you genuinely need float[] 
 as well as float values, that might be more convenient in the long 
 run. 


In some instances, there are float[]s, but most often they form part of 
argument lists. e.g. (foo/bar eg (float 0.2f) (float 0.23) (float 0.23) 
etc other ...) I had thought about the *data-readers* approach for reading 
in float literals. As you say the syntax is not particularly clean.

   #myproject/float 3.14
   #f 3.14

vs.

  (float 3.14)

vs.

  3.14f (proposed)

*data-reader* might work great for kernels where I really need float[] 
though.

 #kernel [0.12 0.23, 0.12]

vs.

 (float-array [0.12 0.23, 0.12])


-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

recursion question

2012-08-14 Thread John Holland
I've been doing some programming exercises in Clojure, I've run into one I 
don't know how to approach. If anyone can just give me the strategy to use 
on this that'd be great. Here is the problem statement:

Given an array of ints, is it possible to choose a group of some of the 
ints, such that the group sums to the given target? 


sample calls would be like:

(groupSum [2, 4, 8] 10) → true
(groupSum [2, 4, 8] 14) → true
(groupSum [2, 4, 8]  9) → false

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: recursion question

2012-08-14 Thread Raoul Duke
¿
take the first #.
subtract that from the goal.
now ask if the remaining #s can sum to the now-lesser goal.
lather rinse repeat.
don't forget a base case.
watch your cpu heat very quickly up on even slightly longer lists.
?

On Tue, Aug 14, 2012 at 4:13 PM, John Holland jbholl...@gmail.com wrote:
 I've been doing some programming exercises in Clojure, I've run into one I
 don't know how to approach. If anyone can just give me the strategy to use
 on this that'd be great. Here is the problem statement:

 Given an array of ints, is it possible to choose a group of some of the
 ints, such that the group sums to the given target?


 sample calls would be like:

 (groupSum [2, 4, 8] 10) → true
 (groupSum [2, 4, 8] 14) → true
 (groupSum [2, 4, 8]  9) → false

 --
 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 unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: recursion question

2012-08-14 Thread Raoul Duke
sorry take the first# actually is meant to be worded as, in turn,
take out 1 of each of the #s, and recurse on what remains so that you
are doing the permutations at each level of the recursion/tree.

On Tue, Aug 14, 2012 at 4:15 PM, Raoul Duke rao...@gmail.com wrote:
 ¿
 take the first #.
 subtract that from the goal.
 now ask if the remaining #s can sum to the now-lesser goal.
 lather rinse repeat.
 don't forget a base case.
 watch your cpu heat very quickly up on even slightly longer lists.
 ?

 On Tue, Aug 14, 2012 at 4:13 PM, John Holland jbholl...@gmail.com wrote:
 I've been doing some programming exercises in Clojure, I've run into one I
 don't know how to approach. If anyone can just give me the strategy to use
 on this that'd be great. Here is the problem statement:

 Given an array of ints, is it possible to choose a group of some of the
 ints, such that the group sums to the given target?


 sample calls would be like:

 (groupSum [2, 4, 8] 10) → true
 (groupSum [2, 4, 8] 14) → true
 (groupSum [2, 4, 8]  9) → false

 --
 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 unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: recursion question

2012-08-14 Thread John Holland
I thought of doing something like that, but part of the requirements is 
that the sum could be achieved with *some of the numbers in the vector.

On Tuesday, August 14, 2012 7:15:27 PM UTC-4, raould wrote:

 ¿ 
 take the first #. 
 subtract that from the goal. 
 now ask if the remaining #s can sum to the now-lesser goal. 
 lather rinse repeat. 
 don't forget a base case. 
 watch your cpu heat very quickly up on even slightly longer lists. 
 ? 

 On Tue, Aug 14, 2012 at 4:13 PM, John Holland 
 jbho...@gmail.comjavascript: 
 wrote: 
  I've been doing some programming exercises in Clojure, I've run into one 
 I 
  don't know how to approach. If anyone can just give me the strategy to 
 use 
  on this that'd be great. Here is the problem statement: 
  
  Given an array of ints, is it possible to choose a group of some of the 
  ints, such that the group sums to the given target? 
  
  
  sample calls would be like: 
  
  (groupSum [2, 4, 8] 10) → true 
  (groupSum [2, 4, 8] 14) → true 
  (groupSum [2, 4, 8]  9) → false 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
 your 
  first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  For more options, visit this group at 
  http://groups.google.com/group/clojure?hl=en 


-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: recursion question

2012-08-14 Thread Raoul Duke
On Tue, Aug 14, 2012 at 4:17 PM, John Holland jbholl...@gmail.com wrote:
 I thought of doing something like that, but part of the requirements is that
 the sum could be achieved with *some of the numbers in the vector.

in the stupidest approach that is just the same thing as all of the
numbers in the vector with a generator/filter up front that spits out
all the possible 1 length vectors, 2 length vectors, etc. derived from
the total vector? boy i'm just making you think along worse lines
performance-wise, aren't i? like the republicans say, just do the
opposite of whatever i'm saying to do... :-)

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: recursion question

2012-08-14 Thread Raoul Duke
 On Tue, Aug 14, 2012 at 4:17 PM, John Holland jbholl...@gmail.com wrote:
 I thought of doing something like that, but part of the requirements is that
 the sum could be achieved with *some of the numbers in the vector.

the other way of looking at it is that the recursion just quits once
the sum it is carrying along is the desired sum. instead of always
reaching the base case of a unit-length-vector.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: recursion question

2012-08-14 Thread Andy Fingerhut
An additional step on top of Raoul's:

Take the first #, subtract it from the goal, recursively ask if the remaining 
#s can sum to the now-lesser goal.  If so, return yes, or the set of numbers 
that worked (which should include whatever was returned from the recursive 
call, plus the first #)

If not, recursively ask if the remaining #s can sum to the original goal.  If 
so return yes, or the set of numbers that worked (which does not include the 
first #)

In the worst case, that will try all 2^n possible subsets of the collection of 
numbers, and then return false.

There are dynamic programming methods that work faster if the sum of the 
numbers is small enough, but require holding in memory an array of at least N 
bits, where N is the target.

Andy

On Aug 14, 2012, at 4:17 PM, John Holland wrote:

 I thought of doing something like that, but part of the requirements is that 
 the sum could be achieved with *some of the numbers in the vector.
 
 On Tuesday, August 14, 2012 7:15:27 PM UTC-4, raould wrote:
 ¿ 
 take the first #. 
 subtract that from the goal. 
 now ask if the remaining #s can sum to the now-lesser goal. 
 lather rinse repeat. 
 don't forget a base case. 
 watch your cpu heat very quickly up on even slightly longer lists. 
 ? 
 
 On Tue, Aug 14, 2012 at 4:13 PM, John Holland jbho...@gmail.com wrote: 
  I've been doing some programming exercises in Clojure, I've run into one I 
  don't know how to approach. If anyone can just give me the strategy to use 
  on this that'd be great. Here is the problem statement: 
  
  Given an array of ints, is it possible to choose a group of some of the 
  ints, such that the group sums to the given target? 
  
  
  sample calls would be like: 
  
  (groupSum [2, 4, 8] 10) → true 
  (groupSum [2, 4, 8] 14) → true 
  (groupSum [2, 4, 8]  9) → false 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.com 
  Note that posts from new members are moderated - please be patient with 
  your 
  first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com 
  For more options, visit this group at 
  http://groups.google.com/group/clojure?hl=en 
 
 -- 
 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 unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: recursion question

2012-08-14 Thread John Holland
Thanks for all the help!

On Tuesday, August 14, 2012 7:38:58 PM UTC-4, Andy Fingerhut wrote:

 An additional step on top of Raoul's:

 Take the first #, subtract it from the goal, recursively ask if the 
 remaining #s can sum to the now-lesser goal.  If so, return yes, or the set 
 of numbers that worked (which should include whatever was returned from the 
 recursive call, plus the first #)

 If not, recursively ask if the remaining #s can sum to the original goal. 
  If so return yes, or the set of numbers that worked (which does not 
 include the first #)

 In the worst case, that will try all 2^n possible subsets of the 
 collection of numbers, and then return false.

 There are dynamic programming methods that work faster if the sum of the 
 numbers is small enough, but require holding in memory an array of at least 
 N bits, where N is the target.

 Andy

 On Aug 14, 2012, at 4:17 PM, John Holland wrote:

 I thought of doing something like that, but part of the requirements is 
 that the sum could be achieved with *some of the numbers in the vector.

 On Tuesday, August 14, 2012 7:15:27 PM UTC-4, raould wrote:

 ¿ 
 take the first #. 
 subtract that from the goal. 
 now ask if the remaining #s can sum to the now-lesser goal. 
 lather rinse repeat. 
 don't forget a base case. 
 watch your cpu heat very quickly up on even slightly longer lists. 
 ? 

 On Tue, Aug 14, 2012 at 4:13 PM, John Holland jbho...@gmail.com wrote: 
  I've been doing some programming exercises in Clojure, I've run into 
 one I 
  don't know how to approach. If anyone can just give me the strategy to 
 use 
  on this that'd be great. Here is the problem statement: 
  
  Given an array of ints, is it possible to choose a group of some of the 
  ints, such that the group sums to the given target? 
  
  
  sample calls would be like: 
  
  (groupSum [2, 4, 8] 10) → true 
  (groupSum [2, 4, 8] 14) → true 
  (groupSum [2, 4, 8]  9) → false 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.com 
  Note that posts from new members are moderated - please be patient with 
 your 
  first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com 
  For more options, visit this group at 
  http://groups.google.com/group/clojure?hl=en 


 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com javascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

ANN: clojure-maven-plugin 1.3.12

2012-08-14 Thread Mark Derricutt
clojure-maven-plugin 1.3.12

A small patch release of the clojure-maven-plugin has been pushed out to Maven 
Central:

Support for Colin James REPL-y project. Simply add a project dependency on 
REPL-y and it will be used for the clojure:repl goal.
A new configuration flag (spawnInteractiveConsoleOnWindows) to disable process 
spawning on the Windows platform.
plugin
  groupIdcom.theoryinpractise/groupId
  artifactIdclojure-maven-plugin/artifactId
  version1.3.12/version
/plugin

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Handling setting different profiles between different environments

2012-08-14 Thread Dave Kincaid
Being new to functional programming and Lisp in particular there is 
something that's been bugging me for a while. How do people handle having 
different configurations during development for development, testing and 
production? For example, things like data sources, server names, etc are 
often different when you're developing, testing and deploying to 
production. In Java-land the Spring framework profiles work really well for 
doing this. Just specify a profile name as a program argument and global 
variables are setup appropriately.

So I'm wondering how others handle this. In one project recently I setup a 
global map using ^:dynamic and then switched in the appropriate map from a 
command line argument. This somehow doesn't seem the right way to do it. 
Any suggestions? Are there some projects out there that would be good 
examples of this?

Thanks,

Dave

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Rich's The Value of Values and REST

2012-08-14 Thread Conrad
Hi Everyone... Quick question about Rich's latest talk:

In it he eloquently argues that you don't want to systems to communicate 
with each other by calling each other's methods. Instead it is better to 
just move values between systems that can also be queued.

It occurs to me that RESTful web interfaces essentially hide a big chunk of 
state behind a bunch of methods (i.e. the URIs you can GET/PUT/POST to.)

Am I right in thinking that Rich's talk is an argument AGAINST RESTful 
design? It seems to me his talk would suggest the best interface would 
almost be a SOAPy interface, where all communication is to a single URL. 
(Of course unlike SOAP the calls wouldn't consist of method invocations but 
instead consist of a stream of values.)

Is this right?

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: recursion question

2012-08-14 Thread John Holland
Ended up with the following wondering if loop/recur is possible in this 
case?

(defn groupSum [a x] (cond
  (= (count a) 0) false
  (= (first a) x) true
  ( (first a) x) (if ( (count a) 1) (groupSum (rest 
a) x) false)
  :else (or
 (groupSum (rest a) (- x (first a)))
 (groupSum (rest a) x


-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Handling setting different profiles between different environments

2012-08-14 Thread Sean Corfield
On Tue, Aug 14, 2012 at 5:49 PM, Dave Kincaid kincaid.d...@gmail.com wrote:
 So I'm wondering how others handle this. In one project recently I setup a
 global map using ^:dynamic and then switched in the appropriate map from a
 command line argument. This somehow doesn't seem the right way to do it. Any
 suggestions? Are there some projects out there that would be good examples
 of this?

At World Singles, environment control was one of the first things we
switched over to Clojure.

Essentially we have a map of maps - a map with default settings and
then a map for each environment with overrides - and a settings Var
that is a delay of creating the merged map for the current host (by
looking up the local hostname in the override maps). That's a gross
simplification but it should give you an idea of what we're doing.

The application just accesses @worldsingles.environment/settings and
it's created on first access and cached for subsequent access (because
of delay).
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.logic project.clj file

2012-08-14 Thread Brent Millare
Well just using leiningen2 and then lein repl, and then

user= (require 'clojure.core.logic)
FileNotFoundException Could not locate clojure/core/logic__init.class or 
clojure/core/logic.clj on classpath:   clojure.lang.RT.load (RT.java:432)

If I change it, then it works.


On Tuesday, August 14, 2012 12:32:26 AM UTC-4, David Nolen wrote:

 On Mon, Aug 13, 2012 at 4:38 PM, Brent Millare 
 brent@gmail.comjavascript: 
 wrote: 
  I think the :source-path line in project.clj should be :source-paths 
  [src/main/clojure]. Is :source-path still looked up in leiningen2? 

 Is there something specific you are trying to do? 

 David 


-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure.logic project.clj file

2012-08-14 Thread David Nolen
On Tue, Aug 14, 2012 at 10:09 PM, Brent Millare brent.mill...@gmail.com wrote:
 Well just using leiningen2 and then lein repl, and then

 user= (require 'clojure.core.logic)
 FileNotFoundException Could not locate clojure/core/logic__init.class or
 clojure/core/logic.clj on classpath:   clojure.lang.RT.load (RT.java:432)

 If I change it, then it works.

This is a question for the Lein folks. I only use the project.clj for
interactive development. Perhaps they can chime in?

David

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.logic project.clj file

2012-08-14 Thread Brent Millare
Well just looking at the source, :source-path is never looked up, only 
:source-paths. All project.clj files that are prepped for leiningen2 use 
:source-paths to my knowledge.

On Tuesday, August 14, 2012 10:20:50 PM UTC-4, David Nolen wrote:

 On Tue, Aug 14, 2012 at 10:09 PM, Brent Millare 
 brent@gmail.comjavascript: 
 wrote: 
  Well just using leiningen2 and then lein repl, and then 
  
  user= (require 'clojure.core.logic) 
  FileNotFoundException Could not locate clojure/core/logic__init.class or 
  clojure/core/logic.clj on classpath:   clojure.lang.RT.load 
 (RT.java:432) 
  
  If I change it, then it works. 

 This is a question for the Lein folks. I only use the project.clj for 
 interactive development. Perhaps they can chime in? 

 David 


-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Handling setting different profiles between different environments

2012-08-14 Thread Dave Kincaid
Thanks, Sean. I really like that approach. I wasn't even aware of the delay 
macro. Very cool. So much awesome stuff in Clojure I feel like I'll never 
learn it all.



On Tuesday, August 14, 2012 8:33:49 PM UTC-5, Sean Corfield wrote:

 On Tue, Aug 14, 2012 at 5:49 PM, Dave Kincaid 
 kincai...@gmail.comjavascript: 
 wrote: 
  So I'm wondering how others handle this. In one project recently I setup 
 a 
  global map using ^:dynamic and then switched in the appropriate map from 
 a 
  command line argument. This somehow doesn't seem the right way to do it. 
 Any 
  suggestions? Are there some projects out there that would be good 
 examples 
  of this? 

 At World Singles, environment control was one of the first things we 
 switched over to Clojure. 

 Essentially we have a map of maps - a map with default settings and 
 then a map for each environment with overrides - and a settings Var 
 that is a delay of creating the merged map for the current host (by 
 looking up the local hostname in the override maps). That's a gross 
 simplification but it should give you an idea of what we're doing. 

 The application just accesses @worldsingles.environment/settings and 
 it's created on first access and cached for subsequent access (because 
 of delay). 
 -- 
 Sean A Corfield -- (904) 302-SEAN 
 An Architect's View -- http://corfield.org/ 
 World Singles, LLC. -- http://worldsingles.com/ 

 Perfection is the enemy of the good. 
 -- Gustave Flaubert, French realist novelist (1821-1880) 


-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Handling setting different profiles between different environments

2012-08-14 Thread Nelson Morris
On Tue, Aug 14, 2012 at 7:49 PM, Dave Kincaid kincaid.d...@gmail.com wrote:
 Being new to functional programming and Lisp in particular there is
 something that's been bugging me for a while. How do people handle having
 different configurations during development for development, testing and
 production? For example, things like data sources, server names, etc are
 often different when you're developing, testing and deploying to production.
 In Java-land the Spring framework profiles work really well for doing this.
 Just specify a profile name as a program argument and global variables are
 setup appropriately.

 So I'm wondering how others handle this. In one project recently I setup a
 global map using ^:dynamic and then switched in the appropriate map from a
 command line argument. This somehow doesn't seem the right way to do it. Any
 suggestions? Are there some projects out there that would be good examples
 of this?

 Thanks,

 Dave


I've been using lein2's profiles combined with
https://github.com/weavejester/environ recently.  The :dev and :test
profiles can declare the keys for their setup, and production can
declare them as environmental variables.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.logic project.clj file

2012-08-14 Thread David Nolen
On Tue, Aug 14, 2012 at 10:31 PM, Brent Millare brent.mill...@gmail.com wrote:
 Well just looking at the source, :source-path is never looked up, only
 :source-paths. All project.clj files that are prepped for leiningen2 use
 :source-paths to my knowledge.

Should core.logic support specific versions of Lein? Ideally Lein 2
would support Lein 1.X files.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en