Walking a tree
Good morning everyone! I have a problem that I have been struggling with for a few days now. I have a directed acyclic graph that I am trying to walk, and can't seem to figure out a to prevent my walking already visited branches. Here is the code (def values [{:v a :parent [b]} {:v b :parent [c]} {:v c :parent [d e]} {:v d :parent [f]} {:v e :parent [f]} {:v f}]) As you can see, I have a vector of records, each with a value and a vector of parents. A node can have more than zero or more parents. a o | b o | c o |\ d o o e |/ f o Here is the fruits of several attempts ... (defn walk-tree ([values] (letfn [(in? [seq elm] (some #(= elm %) seq)) (walk [already id] (when-not (in? already id) (when-let [n (some #(if (= id (:v %)) %) values)] (lazy-seq (cons (:v n) (mapcat #(walk (conj already (:v n)) %) (:parent n)))] (walk #{} (:v (first values)) I was hoping to use the set as a way to record which nodes have been visited. Unfortunately as you might be able to tell, that's not going to work. The result of running this is (a b c d f e f) Notice that f gets in the list twice. One way to do it would be to make a set out of it, but that eliminates the laziness aspect. Can anyone point me in the right direction here? Thanks, Raju -- -- 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/groups/opt_out.
Re: Walking a tree
Dear Stanislav, Thank you. You got me going down the right path. Upon looking around for a BFS solution, I came across this blog post http://hueypetersen.com/posts/2013/06/25/graph-traversal-with-clojure/that had me going down the right direction. Which leads me to Carlo's response -- You are SO right. It was mapcat that was hurting me. Thank you all. I do appreciate this. I will keep digging, but Carlo's prompt response definitely got me past this rut. Warm regards, Raju -- -- 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/groups/opt_out.
Light Table - a new IDE concept
This is an awesome implementation of Brett Victors Inventing On Principle [http://vimeo.com/36579366] using Clojure and Noir by Chris Granger (who also wrote Noir). Figured I would share it with the group. http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/ Raju -- 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: Screencast: Clojure + Emacs + slime + swank + cake + Overtone
Agreed. This is a very informative screencast. Thanks Sam. Raju On Jun 17, 3:21 pm, John Toohey j...@parspro.com wrote: Excellent screencast. On Thu, Jun 16, 2011 at 11:16, Sam Aaron samaa...@gmail.com wrote: Hi there, I just finished making a screencast primarily for new Overtone users on how to get set up with Emacs as a primary editor: http://vimeo.com/25190186 It turns out that this should be pretty useful for Clojure hackers in general as it's really a screencast on how to set up a Clojure environment using Emacs slime, swank and cake. Just s/Overtone/your-project/ Of course, it's also great if you're interested in making music with programming languages :-) 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 -- ~JT -- 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: Emacs setup - quick navigation to files and definitions
emacs-nav is a lightweight project explorer for emacs that I have found useful - https://code.google.com/p/emacs-nav/ It has the ability to grep the directory structure for a symbol (Press 'g' when the cursor is in the emacs-nav window). I find that handy to search for function names across projects. Disclaimer - Clojure for me right now is only getting to be a serious hobby so I am not certain this will scale :) On a side note - many thanks to Glen Stampoultzis for the ctrl-x ctrl- i tip ... Works like a charm. Beats the heck out of ctrl-s :) Hope this helps. Raju On Jun 15, 5:40 am, Kelvin Ward kelvin.d.w...@googlemail.com wrote: In my experience ECB and Speedbar (both come with CEDET) is the only option. I think that speedbar may be available without cedet, but it seems less functional. ECB can keep the speedbar window fixed regardless of closing/opening other emacs windows. It's not a nice as IDEs I'd say, but certainly does work, showing a tree of directories, clojure files and clojure functions/defs. CEDET does look quite the overwhelming install, but it wasn't that bad. I found several of the default ecb/speedbar behaviours unpleasant and fixed them with the right customisation. Right now, having to double, instead of single click, on ecb windows is the most annoying. Some settings I have in my emacs config, some of which I won't remember why I set them: (speedbar-add-supported-extension .clj) (setq ecb-use-speedbar-instead-native-tree-buffer 'dir) (setq speedbar-show-unknown-files t) (setq speedbar-tag-regroup-maximum-length 100) (setq ecb-primary-secondary-mouse-buttons 'mouse-1--C-mouse-1) (setq ecb-speedbar-buffer-sync nil) (setq speedbar-tag-hierarchy-method '(speedbar-sort-tag-hierarchy)) (setq ecb-auto-expand-directory-tree nil) My emacs setup files might helphttps://bitbucket.org/enerqi/emacs-setup/src such as src/elisp/rc/emacs-rc-cedet.el. However, I've saved a copy of cedet with my elisp files. With recent versions of emacs (23+ or 24+) cedet comes with emacs and I had to delete the cedet shipped with emacs to avoid changing my emacs config. On Jun 13, 2:50 am, yair yair@gmail.com wrote: Hi, With swank and slime all set-up along with CDT, further improved by slime autocomplete, my emacs setup is getting pretty close to being a full featured, highly clojure focused IDE. One thing I am struggling with while working on a larger than usual project (i.e. 7 source files some of which have 200-300 lines) is quickly navigating between source files and the definitions within them. I took a look at CEDET but it seemed a bit overwhelming, and I wasn't sure the effort would be worth it as I couldn't tell if clojure would then be supported within it. So, which plugins do you use in emacs for navigating between clojure source files and definitions? 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
Re: New to Clojure
Hi Santosh, I have been playing around with Clojure for some time now, and outside of echoing most of the suggestions listed above (specifically StackOverFlow hints/tricks, OSS projects on GitHub/BitBucket and most importantly the REPL with Leiningen) I have one more suggestion - Being a Java guy (and Ruby) myself, one thing I found myself struggling with is the functional nature of Clojure. I still struggle with it so I will elaborate on how I am trying to work around it. - The Little Schemer [http://www.amazon.com/Little-Schemer-Daniel-P- Friedman/dp/0262560992] - I found this book to be a good refresher on recursion, and thinking along those lines. I just went through it (I wrote all the code samples in Clojure), and am starting the next one in the series which is - The Seasoned Schemer [http://www.amazon.com/Seasoned-Schemer- Daniel-P-Friedman/dp/026256100X] I started playing with the 99 Lisp Programs exercise suggested by Shantanu a while back, and one thing that helped me was to use Clojure core only (rather than using Clojure Contrib along with it). YMMV. There are few books out there that can help - The Joy of Clojure IMO being a really good one to pick, but it's one that you should read after getting your hands dirty with Clojure first. Practical Clojure is another good book, and relatively new so it covers some of the newer constructs in Clojure as compared to Stu's Programming Clojure (Though I believe Aaron Bedra is working on the second edition of that book). Finally, I agree with many others on this thread - Emacs is a popular editor among many a lisp programmer, and Clojure is no different. Unfortunately if you are not familiar with it, it presents a two-fold problem - you need to learn to use the editor along with learning Clojure. My take on this - if you are familiar with an IDE like Eclipse or NetBeans or even IntelliJ just download the plugin and start writing code. Hope this helps. Raju On Jun 8, 12:49 am, Santosh M santoshvmadhyas...@gmail.com wrote: Thank you mike will definitely go through the links. :). I don't have any background of lisp. Cheers Santosh On Jun 7, 3:30 pm, Mike Anderson mike.r.anderson...@gmail.com wrote: Hi Santosh, I was in your position a little over a year ago. Some recommendations that may help: - If you're coming from a Java environment, you may find it easiest to move to Clojure by using a Clojure plugin for your favourite Java IDE. I use the Counterclockwise plugin for Eclipse which is excellent, but I've heard great things about Enclojure for Netbeans too. - It's worth watching the video for Clojure for Java Programmers by Clojure creator Rich Hickey -http://blip.tv/clojure/clojure-for-java-programmers-1-of-2-989128 - I also strongly recommend this video if you want to understand Clojure's data structures and approach to concurrency:http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey - I've found StackOverflow to be a great resource for Clojure tricks and hints Hope this helps - and good luck! Mike. On Jun 7, 8:30 pm, Santosh M santoshvmadhyas...@gmail.com wrote: I want to learn clojure. I already know Java. Please tell me how to proceed. Regards Santosh -- 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: Emacs auto-complete plugin for slime users
This is awesome! Thank you. After installing auto-complete and following the instructions on your github page, works like a charm. Brilliant work. Regards, Raju On Oct 16, 12:27 am, Jarl Haggerty fictivela...@gmail.com wrote: Should autocomplete work in the swank repl? It works perfectly in a clj buffer but nothing happens in the repl. On Aug 19, 7:46 am, Phil Hagelberg p...@hagelb.org wrote: On Thu, Aug 19, 2010 at 6:21 AM, Steve Purcell st...@sanityinc.com wrote: I guess Phil's very busy, but if he can apply this patch, then the regular swank-clojure 1.3.0-SNAPSHOT on clojars should end up containing the fix. Just applied this patch and pushed to github and clojars. Thanks! -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
Re: post your feedback on the conj
A big shout-out to Relevance, sponsors, speakers and attendees (with my own heartfelt gratitude towards Alan et al.) - Thank you! A great conference. Superb talks, and smooth execution, down right to making sure everyone could get to and from the social outings and to-from the airports. It was nice to put faces on the names and twitter handles of many Clojurians. I look forward to seeing the lazy-sequence of conferences being evaluated in the future :) With my utmost appreciation, Warm regards, Raju On Oct 24, 12:03 pm, Stuart Halloway stuart.hallo...@gmail.com wrote: If you were at Clojure-conj, you can post your feedback on talks through SpeakerRate athttp://speakerrate.com/events/613-clojure-conj. Please do, so we can make (second conj) even better! It was terrific meeting so many of you for the first time. Thanks again to all the attendees, speakers, sponsors, and volunteers for making the conj great. Stu Stuart Halloway Clojure/core team at Relevancehttp://clojure.comhttp://thinkrelevance.com -- 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.contrib.repl-utils show
Hello! I figured it out. For the record, it was me being stupid about it. The problem was doing a (use 'clojure.contrib.repl-utils) would barf because 'source' is declared in both clojure.repl and clojure.contrib.repl-utils (This has probably to do with what Sean said - some repl functions are being promoted to core). I needed to do a (use '[clojure.contrib.repl-utils :only (show)]) - this way the name collision would be avoided. (I am not sure why emacs tab-autocomplete would not show repl-utils as an option, but it may have to do with the collision). The lab-repl script loads the 'show' function this way. That's why it worked with lab-repl but not with a 'lein swank' since with lein I have to explicitly 'use' any contrib libraries. I am sorry for the confusion. Please forgive me. Warm regards, Raju On Jun 1, 5:14 pm, looselytyped raju.gan...@gmail.com wrote: Hi Sean, Yes, it certainly looks like it's being pulled into clojure core. Thank you for the response. If I may say so - I think your series on vimeo is awesome. Thank you for taking the time and making the effort. Kind regards, Raju On Jun 1, 11:13 am, Sean Devlin francoisdev...@gmail.com wrote: Keep in mind thatREPL-utils is being discussed for inclusion in core in 1.2. Therefore, any edge build will have to pay extra attention to what is going on. This will be easier to track when frozen betas RC's come out. Sean On Jun 1, 10:52 am, looselytyped raju.gan...@gmail.com wrote: Hi Meikel, Thank you for the response. I did not do that, but a quick glance at the clojure.contribgithub repo tells me there is no 'show' function in it. I will try it at home (it's on my home computer). It's odd because it was working just fine - then I did a 'lein clean' and 'lein deps' and it was then I could not refer to 'show'. Kind regards, Raju On Jun 1, 1:28 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Jun 1, 4:16 am, looselytyped raju.gan...@gmail.com wrote: For some reason, the 'show' function from clojure.contrib.repl-utils does not work. In fact the only completions I get when trying to get torepl-* are clojure.contrib.repl-ln clojure.contrib.repl_ln Did you (require 'clojure.contrib.repl-ln)? Maybe labrepl does that for you. Sincerely Meikel -- 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.contrib.repl-utils show
Hello! I figured it out. For the record, it was me being stupid about it. The problem was doing a (use 'clojure.contrib.repl-utils) would barf because 'source' is declared in both clojure.repl and clojure.contrib.repl-utils (This has probably to do with what Sean said - some repl functions are being promoted to core). I needed to do a (use '[clojure.contrib.repl-utils :only (show)]) - this way the name collision would be avoided. (I am not sure why emacs tab-autocomplete would not show repl-utils as an option, but it may have to do with the collision). The lab-repl script loads the 'show' function this way. That's why it worked with lab-repl but not with a 'lein swank' since with lein I have to explicitly 'use' any contrib libraries. I am sorry for the confusion. Please forgive me. Warm regards, Raju On Jun 1, 5:14 pm, looselytyped raju.gan...@gmail.com wrote: Hi Sean, Yes, it certainly looks like it's being pulled into clojure core. Thank you for the response. If I may say so - I think your series on vimeo is awesome. Thank you for taking the time and making the effort. Kind regards, Raju On Jun 1, 11:13 am, Sean Devlin francoisdev...@gmail.com wrote: Keep in mind thatREPL-utils is being discussed for inclusion in core in 1.2. Therefore, any edge build will have to pay extra attention to what is going on. This will be easier to track when frozen betas RC's come out. Sean On Jun 1, 10:52 am, looselytyped raju.gan...@gmail.com wrote: Hi Meikel, Thank you for the response. I did not do that, but a quick glance at the clojure.contribgithub repo tells me there is no 'show' function in it. I will try it at home (it's on my home computer). It's odd because it was working just fine - then I did a 'lein clean' and 'lein deps' and it was then I could not refer to 'show'. Kind regards, Raju On Jun 1, 1:28 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Jun 1, 4:16 am, looselytyped raju.gan...@gmail.com wrote: For some reason, the 'show' function from clojure.contrib.repl-utils does not work. In fact the only completions I get when trying to get torepl-* are clojure.contrib.repl-ln clojure.contrib.repl_ln Did you (require 'clojure.contrib.repl-ln)? Maybe labrepl does that for you. Sincerely Meikel -- 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.contrib.repl-utils show
Hi Meikel, Thank you for the response. I did not do that, but a quick glance at the clojure.contrib github repo tells me there is no 'show' function in it. I will try it at home (it's on my home computer). It's odd because it was working just fine - then I did a 'lein clean' and 'lein deps' and it was then I could not refer to 'show'. Kind regards, Raju On Jun 1, 1:28 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Jun 1, 4:16 am, looselytyped raju.gan...@gmail.com wrote: For some reason, the 'show' function from clojure.contrib.repl-utils does not work. In fact the only completions I get when trying to get torepl-* are clojure.contrib.repl-ln clojure.contrib.repl_ln Did you (require 'clojure.contrib.repl-ln)? Maybe labrepl does that for you. Sincerely Meikel -- 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.contrib.repl-utils show
Hi Sean, Yes, it certainly looks like it's being pulled into clojure core. Thank you for the response. If I may say so - I think your series on vimeo is awesome. Thank you for taking the time and making the effort. Kind regards, Raju On Jun 1, 11:13 am, Sean Devlin francoisdev...@gmail.com wrote: Keep in mind that REPL-utils is being discussed for inclusion in core in 1.2. Therefore, any edge build will have to pay extra attention to what is going on. This will be easier to track when frozen betas RC's come out. Sean On Jun 1, 10:52 am, looselytyped raju.gan...@gmail.com wrote: Hi Meikel, Thank you for the response. I did not do that, but a quick glance at the clojure.contrib github repo tells me there is no 'show' function in it. I will try it at home (it's on my home computer). It's odd because it was working just fine - then I did a 'lein clean' and 'lein deps' and it was then I could not refer to 'show'. Kind regards, Raju On Jun 1, 1:28 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Jun 1, 4:16 am, looselytyped raju.gan...@gmail.com wrote: For some reason, the 'show' function from clojure.contrib.repl-utils does not work. In fact the only completions I get when trying to get torepl-* are clojure.contrib.repl-ln clojure.contrib.repl_ln Did you (require 'clojure.contrib.repl-ln)? Maybe labrepl does that for you. Sincerely Meikel -- 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
clojure.contrib.repl-utils show
Hi! I created a new project using 'lein new project_name and then modified the project.clj file to look like this - (defproject datastructures 1.0.0-SNAPSHOT :dependencies [[org.clojure/clojure 1.2.0-master-SNAPSHOT] [org.clojure/clojure-contrib 1.2.0-SNAPSHOT] [ant/ant 1.6.5] [jline 0.9.94] [org.apache.maven/maven-ant-tasks 2.0.10]] :dev-dependencies [[swank-clojure 1.2.1] [autodoc 0.7.0]]) I did a 'lein deps' and then a 'lein swank' - I switched over the emacs and did a slime-connect [I am using the emacs-starter-kit with clojure-mode, and swank-clojure installed via ELPA). For some reason, the 'show' function from clojure.contrib.repl-utils does not work. In fact the only completions I get when trying to get to repl-* are clojure.contrib.repl-ln clojure.contrib.repl_ln I noticed that there is now a clojure.repl namespace with a few methods like apropos but no 'show'. Furthermore, when using labrepl (from relevance) and doing a script/ swank 'show' works just fine. Both lib directories contain the same jars labrepl/lib = clojure-1.2.0-master-20100528.120302-79.jar clojure-contrib-1.2.0-20100528.120551-119.jar new_project/lib = clojure-1.2.0-master-20100528.120302-79.jar clojure-contrib-1.2.0-20100528.120551-119.jar Is there something I am missing? Thank you! -- 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 Conference Poll
I concur. Columbus, OH is a pretty good location :D [But then, I am just being selfish] In all seriousness, it does act as a pretty central location in the midwest region IMO. Raju On Jan 22, 4:15 pm, Wilson MacGyver wmacgy...@gmail.com wrote: I vote let's turn this into a clojure vacation, and hold it in an exotic location. Otherwise, hey, Columbus Ohio is as good as any other city. :) On Fri, Jan 22, 2010 at 3:50 PM, Sean Devlin francoisdev...@gmail.com wrote: Clearly you haven't taken into account that Philadelphia is more central wrt the big cities :) On Jan 22, 3:32 pm, Fogus mefo...@gmail.com wrote: Since Clojure is clearly an East-Coast language, I suggest DC as the most logical locale. (hopes someone buys this line of reasoning) -m -- 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 -- Omnem crede diem tibi diluxisse supremum. -- 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