Re: Source code as metadata

2012-03-31 Thread Nathan Matthews

On 31 Mar 2012, at 00:00, Cedric Greevey wrote:

 On Fri, Mar 30, 2012 at 6:17 PM, Lee Spector lspec...@hampshire.edu wrote:
 
 On Mar 30, 2012, at 5:11 PM, Cedric Greevey wrote:
 
 That opens a giant can of worms. How, for example, do we discover that
 (partial * 2) and #(* % 2) and (fn [x] (* 2 x)) and #(+ %1 %1) are all
 equal? Nevermind once we get into situations like #(reduce + (map
 (constantly 1) %) equals #(loop [n 0 s (seq %)] (if s (recur (inc n)
 (next s)) n) equals count.
 
 In fact that's an uncomputable can of worms.
 
 I was pretty sure it smelled like halting problem; thanks for confirming. :)

Agreed, but I'm not suggesting determining whether two forms are 
computationally equivalent, just if two forms are 
literally equivalent. I know it wouldn't cover all cases, but cases like:

(= (partial * 2) (partial * 2))

it would cover, which would seem like an improvement over the situation today. 
I suppose my bigger point is if code is data 
when thy isn't the code for functions available for analysis at runtime? 

 
 -- 
 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: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-31 Thread David Powell
As an aside:

Fingertrees are an interesting way to keep a collection that can
efficiently compute means over its values, or a window of its values.

https://gist.github.com/672592

-- 
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

Re: Better ways to make time tansformations?

2012-03-31 Thread Petr Gladkikh
I'd suggest using java.util.concurrent.TimeUnit
for example TimeUnit.MILLISECONDS.toDays(1234543211);
or, since we're on Clojure list (.toDays
java.util.concurrent.TimeUnit/MILLISECONDS 1234543211)

For more complex tasks Joda Time is excellent choice.

On Sat, Mar 31, 2012 at 4:51 AM, Goldritter
marcus.goldritter.lind...@googlemail.com wrote:
 I wanted to track a program and set a maximum runtime for it in a way
 which is readable for the user. So I needed to write a time
 tansformation which I could use in my track function.
 First I wanted to use something like the 'defunits' macro from Let
 over Lambda from Doug Hoyte, but I'm not so fit in LISP and Clojure
 to write/understand it :(.

 So I use following two function:

 (defn unit-of-time
  [value unit]
  (unit-of-time value unit) returns the value in relation to the
 defined unit in seconds.
 Example: (unit-of-time 10 :minute) will return 600 and (unit-of-time
 3 :millisecond) 3/1000.
 following Keywords are supported:
 :second
 :minute
 :houre
 :day
 :millisecond
 :microsecond
 :nanosecond
  (* value (case unit
             :second 1
             :minute 60
             :houre 3600
             :day 86400
             :millisecond 1/1000
             :microsecond 1/100
             :nanosecond 1/10)))

 (defn transform-time
  [value from to]
  (transform-time value from to) calculates the value from the unit
 'from' to the unit 'to'
  (/ (unit-of-time value from)
     (unit-of-time 1 to)))

 The functions, but now I would know if there might be a better way to
 transform for example a time value given in minutes into the
 appropriate milli- or nanosecond value?

 --
 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



-- 
Petr Gladkikh

-- 
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


A simple (and naive) online whiteboard using Aleph ClojureScript

2012-03-31 Thread Nicolas Buduroi
Hi everyone, I've been experimenting with ClojureScript and Aleph lately
and made this sample application. It's a naive implementation of an online
whiteboard. It's under a hundred line of code so it's a quick read:

https://github.com/budu/board

The Clojure web development story is getting better and better everyday,
bit thanks to everyone involved!

-- 
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: A simple (and naive) online whiteboard using Aleph ClojureScript

2012-03-31 Thread Nicolas Buduroi
On Saturday, March 31, 2012 7:35:03 PM UTC-4, jun lin wrote:

 Maybe you can create an online demo site?

 
Yes good idea, I'll try to get it running on Heroku tomorrow.

-- 
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: Source code as metadata

2012-03-31 Thread Jeff Weiss
I believe the latest code does capture closures properly.  I haven't tested 
all kinds of crazy corner cases, but it does work for all my closures.

From browsing git, it looks like the project.clj version hasn't been 
incremented in 7 months, and the fix for closures came in after that.  If 
you're using serializable.fn from a maven repo, it is out of date, AFAICT.

-jeff

On Friday, March 30, 2012 3:07:53 PM UTC-4, Phil Hagelberg wrote:

 Nathan Matthews nathan.r.matth...@gmail.com writes:

  I wanted to serialise functions and send them over the network. The
  problem with serializable-fn is that it doesn't capture closures.

 It's designed to capture closures; if it doesn't that would be an
 (unsurprising) bug.

 -Phil



-- 
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