Re: Is there a tool to display all the references to a symbol in a project?

2014-12-03 Thread Alex Hammel
If you're OK with using an editor that's not emacs, most of them have some
kind of ctags plugin these days. There's a decent looking ctags config for
clojure here  (haven't tried it
myself).

On Wed, Dec 3, 2014 at 7:40 AM, Ashton Kemerling 
wrote:

> I would recommend the silver searcher (ag) if the project is large, as it
> is much faster.
>
> --Ashton
>
> Sent from my iPhone
>
> On Dec 3, 2014, at 8:34 AM, Gary Trakhman  wrote:
>
> I use grep or ack. It's not exact, but it works.
>
> On Wednesday, December 3, 2014, Yehonathan Sharvit 
> wrote:
>
>> Is there a tool to display all the references to a symbol in a project?
>>
>> Preferably without using emacs.
>>
>> Thanks.
>>
>> --
>> 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 unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>  --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>  --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: My first implementation of Sieve of Eratosthenes. cons please

2014-11-26 Thread Alex Hammel
Or there's this approach, based on an example from the docs
, which gives an infinite
lazy seq of primes:

(defn divisible-by? [x y]
  (zero? (mod x y)))

(defn sieve [s]
  (cons (first s)
(lazy-seq
 (sieve (filter #(not (divisible-by? % (first s)))
(rest s))

(def primes
  (cons 2
(sieve (iterate (partial + 2) 3

Caveat: 'infinite' here means 'about 1500 items before the stack blows up',
but you get the idea.

As to actually implementing Eratosthenes, you might try translating this
take on it 
(Python) into a functional style (here's my humble attempt
 at a C++ translation). The idea
is to lazily maintain a set of the smallest known composites you're likely
to encounter, updating as you go along. You may also be interested in the
awe-inspiring paper The Genuine Sieve of Eratosthenes
 (PDF).


On Wed, Nov 26, 2014 at 3:02 PM, bernardH 
wrote:

> Hi,
> As has been said, this is not SoE. But my take would be something along :
> (reduce
>(fn [primes number]
>  (if (some zero? (map (partial mod number) (take-while #(<= %
> (Math/sqrt number)) primes)))
>primes
>(conj primes number)))
>[2]
>(take n (iterate inc 3)))
>
> But I'm a noob, so it migth be the bilnd leading the blind ☺
>
> Best Regards,
>
> b.
>
>
> On Wednesday, November 26, 2014 3:52:44 PM UTC+1, Chernyshev Alex wrote:
>>
>> (defn not-divisible-by?[num denum]
>>   (not (= (mod num denum) 0)))
>>
>> (defn div-nums [denum bound]
>> (for [x (range 2 bound) :when (not-divisible-by? x denum)] x))
>>
>> (defn divisible? [coll denum]
>>   (empty? (filter #(and (not= denum %) (not(not-divisible-by? denum %)))
>> coll)))
>>
>> (defn generate-primes
>>   "Sieve of Eratosthenes"
>>   [n]
>>   (let [src (div-nums 2 n)]
>> (cons 2 (for [x src :when (divisible? src x)] 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: My first implementation of Sieve of Eratosthenes. cons please

2014-11-26 Thread Alex Hammel
A few observations:

I believe what you have implemented is trial division
, rather than the SoE.

It looks a little weird to me to have a predicate called `not-foo?`
starting with a call to `not`. I would rather define a `foo?` predicate,
and then do `(def not-foo? (complement foo?))` if needed.

The `div-nums` function is used only to generate odd numbers greater than
2, but the built in `range` can do that admirably with `(range 3 n 2)`.

In general, `(for [x coll :when (pred x)] x)` can be more idiomatically
spelled `(filter pred coll)`.

`(empty? (filter pred coll))` can be spelled `(not-any? pred coll)`

`(= n 0)` can be spelled `(zero? n)` [thanks, kibit
!]

Here's my go .

Cheers,
Alex

On Wed, Nov 26, 2014 at 6:52 AM, Chernyshev Alex <
chernyshev.alexan...@gmail.com> wrote:

> (defn not-divisible-by?[num denum]
>   (not (= (mod num denum) 0)))
>
> (defn div-nums [denum bound]
> (for [x (range 2 bound) :when (not-divisible-by? x denum)] x))
>
> (defn divisible? [coll denum]
>   (empty? (filter #(and (not= denum %) (not(not-divisible-by? denum %)))
> coll)))
>
> (defn generate-primes
>   "Sieve of Eratosthenes"
>   [n]
>   (let [src (div-nums 2 n)]
> (cons 2 (for [x src :when (divisible? src x)] 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: better way to group consecutive numbers in a vector?

2014-11-07 Thread Alex Hammel
Here's my take on the 'add delimiters and split' approach. Bonus `congeal
function, which chunks collections on any condition you like:

(defn- insert-gaps
  [coll pred gap-symbol]
  (reduce (fn [acc x]
(if (pred (peek acc) x)
(conj acc x)
(conj acc gap-symbol x)))
  [(first coll)]
  (rest coll)))

(defn split-coll
  [coll delimiter]
  (->> coll
   (partition-by (partial = delimiter))
   (remove (partial = (list delimiter)

(defn congeal
  [pred coll]
  (let [gap-symbol (gensym)]
(-> coll
(insert-gaps pred gap-symbol)
(split-coll gap-symbol

(defn consecutive? [p q]
  (= (inc p) q))

(println (congeal consecutive? [1 3 4 5 7 9 10 11 12]))
#=> ((1) (3 4 5) (7) (9 10 11 12))
(println (congeal < [1 2 3 1 2 3 1 2 3]))
#=> ((1 2 3) (1 2 3) (1 2 3))
(println (congeal not= [:foo :foo :bar :bar :foo :bar]))
#=> ((:foo) (:foo :bar) (:bar :foo :bar))




On Fri, Nov 7, 2014 at 4:09 AM, Paweł Rozynek  wrote:

> (def data '(1 3 4 5 7 9 10 11 12))
> (map #(map last %) (partition-by #(apply - %) (map-indexed vector data)))
> => ((1) (3 4 5) (7) (9 10 11 12))
>
> regards
> PR
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Automat: better FSMs through combinators

2014-05-14 Thread Alex Hammel
This looks really, really cool. Good work!


On Wed, May 14, 2014 at 6:41 AM, Jason Felice wrote:

> Wow, this library looks very useful!
>
> Thanks!
> -Jason
>
>
> On Tue, May 13, 2014 at 5:55 PM, Colin Fleming <
> colin.mailingl...@gmail.com> wrote:
>
>> I'm also very excited about Automat, although I haven't had time to look
>> at it closely yet. Ragel is one of my favourite pieces of software. Here's
>> an article from Zed Shaw about using state charts for networked apps:
>> http://www.zedshaw.com/essays/ragel_state_charts.html. I read an article
>> (or an interview, I can't remember) where he discussed the state machines
>> in Mongrel in more depth, it was fascinating and quite amazing how much it
>> simplified the code, made it much more robust and consistently handled
>> tricky corners of HTTP while easily supporting things like websockets.
>>
>> I'll take a look when I get a moment and provide some feedback - in
>> particular I'm excited about the possibility of compiling state machines
>> without the build time precompile step, I think there are a lot of
>> interesting possibilities with this.
>>
>> Cheers,
>> Colin
>>
>>
>> On 14 May 2014 07:27, Zach Tellman  wrote:
>>
>>> https://github.com/ztellman/automat
>>>
>>> This has been languishing in my Github for a while, for lack of a few
>>> finishing touches on the code and documentation.  I think this is one of
>>> cooler libraries I've written, and beyond the obvious use for parsers, the
>>> set theoretic operators could be a powerful way to specify actions in
>>> response to complex browsing behaviors on a site, or any other number of
>>> things.  I'm excited to see how it's used.
>>>
>>> I'm happy to answer any questions.  Suggestions on how to improve the
>>> documentation are encouraged.
>>>
>>> Zach
>>>
>>> --
>>> 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 unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> 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 unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Potential Intro clojure projects - libraries and ideas with wow factor

2014-04-16 Thread Alex Hammel
Probably. Things like OptaPlanner are the big business use-case for logic
programming, IIRC.


On Wed, Apr 16, 2014 at 1:49 AM, Josh Kamau  wrote:

> Can core.logic be used to implement something like
> http://www.optaplanner.org  ?
>
> Josh
>
>
> On Wed, Apr 16, 2014 at 9:36 AM, utel  wrote:
>
>> Thanks Mikera and Andrew for the ideas. Some interesting suggestions
>> there. I'll discuss these with my fellow devs. Much appreciated.
>>
>>
>> On Tuesday, April 15, 2014 1:14:11 AM UTC+1, Andrew Chambers wrote:
>>>
>>> Clojure logic programming with core.logic (something akin to a sudoku
>>> solver https://gist.github.com/swannodette/3217582 is a good example)
>>> or using datomic to have a database with a time machine and datalog for
>>> queries might be cool (perhaps visualizing the data in the database at
>>> arbitrary times in the past). Both don't really have equivalents in other
>>> languages. Other things that are hard to achieve in other languages would
>>> involve the immutable data structures, concurrency, and macros.
>>>
>>>
>>> On Monday, April 14, 2014 9:15:31 AM UTC+12, utel wrote:

 A handful of developers at the organisation I work at, want to
 encourage interest in Clojure with the aim of using it in production
 amongst the organisation's wider developer community (hundreds of
 developers). We ourselves are Clojure hobbyists.

 We wanted to do this through a basic project (with few moving parts),
 so I wanted to get feedback on a couple of aspects:
 1. Examples of basic project ideas that would be compelling to fellow
 developers not familiar with Clojure (e.g. something useful that you can do
 easily with Clojure that's harder to do in more established languages such
 as Java)
 2. Particular libraries that again had a wow factor towards an
 objective not easily achievable in more established languages (perhaps
 related to data analysis, visualisation, or taking advantage of the benefit
 of lazy evaluation in a novel way as examples).

 I realise these questions are somewhat open-ended, but just wanted to
 spark off some ideas for us through bouncing these questions off the google
 group's members.

 Thanks for any leads!

  --
>> 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 unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.