how to learn clojure ?
All documentation I've seen about clojure assumes knowledge of lisp which I dont have. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
how to learn clojure ?
All documentation I've seen about clojure assumes knowledge of lisp which I dont have. --~--~-~--~~~---~--~~ 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 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 with Lisp and Clojure.
swank-clojure is deprecated, don't use it. Instead start swank from leiningen. I found these instructions how to install clojure support in emacs http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html No need to use elpa with broken packages or starter-kit. Maris On Mar 24, 8:14 am, Tassilo Horn wrote: > mmwaikar writes: > > But the same enter key works properly when I am using Lisp, so why > > shouldn't it be the default in Clojure as well? > > What's considered "properly" for RET is purely subjective. :-) > > But I have to admit that I was wrong. When paredit-mode is enabled, RET > is indeed bound to `paredit-newline', which does indentation > automatically. For me that does the trick for Clojure, Elisp, and CL > buffers... > > > Also, after removing clojure-mode, when I try to install swank- > > clojure, it again installs the clojure-mode, but fails to install > > itself? > > Do you get some error messages? > > Using emacs 24 from bzr, I only added > > (add-to-list 'package-archives > '("technomancy" . "http://repo.technomancy.us/emacs/";) t) > > to get the most recent packages from technomancy listed in M-x > package-list-packages, and there I installed these ones: > > clojure-mode 1.8.0 installed Major mode for Clojure code > slime 20100404.1 installed Superior Lisp Interaction Mode for > Emacs > slime-repl 20100404 installed Read-Eval-Print Loop written in > Emacs Lisp > swank-clojure 1.1.0 installed Slime adapter for clojure > > Bye, > Tassilo -- 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
List comprehension and sets
Is it possible to use list comprehension to generate a set ? For example in scala I can do: for (i <- (2 to 8).toSet[Int]) yield p(i) In clojure this (for [ x (set (range 4))] (* 4 x)) generates a list. -- 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: List comprehension and sets
> Does this actually yield a set in Scala? yes, it does > What is p()? A set constructor? p(i) reads i-nth element from a vector def selectRow(p: Vector[Int], i: Int) = { for (i <- (i - i % 9 to i - i % 9 + 8).toSet[Int]) yield p(i) } -- 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: List comprehension and sets
> (set (for [x (range 4)] (* 4 x))) > ;=> #{0 4 8 12} > > Does that help? yes, 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: interest in STM, where can I start to get knowing well about it?
STM is discussed in this book The Art of Multiprocessor Programming http://www.amazon.com/Art-Multiprocessor-Programming-Maurice-Herlihy/dp/0123705916 On May 18, 8:25 am, jaime wrote: > Hi All, > > I have interest in the implementation of STM, anyone who can suggest > where I can start to find out how it was implemented? > I can probably go read the source code but I'm just a fresher of > Clojure and also need some guides/materials about the internal > mechanism, I guess it likes kind of database implementation (locks & > latches), but I'm not familiar with that field either. > > BTW, I got a Java background and know a little about LISP. > > 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
find first non nil element of sequence
To find first defined Option in scala I do this: sol.find(_.isDefined).getOrElse(None) I managed to do the same in clojure: (some #(if (nil? %) false %) sol) Is there a better way ? -- 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: find first non nil element of sequence
there is find-first in contrib (find-first #(not (nil? %)) sol) On May 27, 3:12 pm, Meikel Brandmeyer wrote: > Hi, > > Am Freitag, 27. Mai 2011 15:56:47 UTC+2 schrieb MarisO: > > > > > To find first defined Option in scala I do this: > > > sol.find(_.isDefined).getOrElse(None) > > > I managed to do the same in clojure: > > > (some #(if (nil? %) false %) sol) > > > Is there a better way ? > > Another way: (first (keep identity coll)). > > user=> (first (keep identity [nil false 1 2 3])) > false > user=> (first (keep identity [nil 1 2 3])) > 1 > user=> (first (keep identity [nil nil nil])) > nil > user=> (first (keep identity [])) > nil > > If your collection does never contain false, you can simply use (some > identity coll). > > 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: New to Clojure -- Errors Are Frustrating
(defn fac [n] (if (= n 1) 1 (* n fac (- n 1 your code tries to multiply n by function this is correct: (defn fac [n] (if (= n 1) 1 (* n (fac (- n 1) On Aug 2, 8:11 am, recurve7 wrote: > In browsing this group I see this topic has been brought up several > times over the past 3 years, so I apologize for revisiting it. > > I just downloaded Clojure and was excited to try it, but so far trying > to move beyond simple examples has often resulted in me making a > mistake that yields a Java exception that presumably is helpful to the > people who wrote Clojure, but doesn't provide me enough direction or > sense of what I did wrong. > > Maybe improvement has been made in Clojure's so far, but it's very > hard for me to think about working in a language that doesn't try to > identify on what line and where on that line it encountered an error > with my input. > > And when I get a Java-exception-style error from Clojure, it does me > no good to copy it in to Google, because I get all these responses > from Java programmers that have nothing to do with Clojure. > > I think it will be hard for Clojure to move beyond the fringe without > its own, unique, Google-searchable error messages and without helpful > positional error feedback for new people like me, who are maybe not > used to its syntax. > > Here's one example where recursion and lack of positional error > feedback make it hard for me, as someone coming from Java, to spot the > error (and seeing "ClassCastException" threw me off and had me > wondering where/how I had done something like that): > > user=> (defn fac [n] (if (= n 1) 1 (* n fac (- n 1 > #'user/fac > user=> (fac 3) > java.lang.ClassCastException: user$fac cannot be cast to > java.lang.Number (NO_SOURCE_FILE:0) > > I will check back in on Clojure to see if it becomes more friendly for > beginners and kids. Thanks for making it and working on it. =) -- 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
reverse a sequence without reverse or rseq
Do you know of any trick to reverse a sequence without reverse or rseq ? I wrote it like this: ((fn rev ([s] (rev '() s)) ([r s] (if (seq s) (rev (cons (first s) r) (rest s)) r )) ) '[1 2 3 5] ) https://gist.github.com/1132357 I wonder if it can be written more shortly. -- 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
par branch in leiningen
I would like to try pvmap and pvreduce. Do I need to build par branch of Clojure ? Is there any way I can make leiningen to use it ? Maris -- 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: aquamacs, slime and clojure on OS X
use this script to download everything you need for clojure development on emacs (aquamacs) git clone https://github.com/technomancy/clojure-mode.git wget -P framemove http://www.emacswiki.org/emacs/download/framemove.el wget -P paredit http://mumble.net/~campbell/emacs/paredit.el wget --no-check-certificate https://github.com/downloads/magit/magit/magit-1.0.0.tar.gz mkdir magit tar --strip-components=1 --directory=magit -xzf magit-1.0.0.tar.gz wget http://download.savannah.gnu.org/releases/color-theme/color-theme-6.6.0.tar.gz mkdir color-theme tar --strip-components=1 --directory=color-theme -xzf color- theme-6.6.0.tar.gz my init.el: ;; clojure-mode (add-to-list 'load-path "~/.emacs.d/clojure-mode") (require 'clojure-mode) ;; paredit (add-to-list 'load-path "~/.emacs.d/paredit") (require 'paredit) ;; color theme (add-to-list 'load-path "~/.emacs.d/color-theme") (require 'color-theme) (eval-after-load "color-theme" '(progn (color-theme-initialize))) ; windmove and framemove (add-to-list 'load-path "~/.emacs.d/framemove") (require 'framemove) (windmove-default-keybindings) (setq framemove-hook-into-windmove t) ;; customizations (menu-bar-mode -1) (show-paren-mode t) (if (boundp 'tool-bar-mode) (tool-bar-mode -1)) (if (boundp 'scroll-bar-mode) (scroll-bar-mode -1)) ;; color profiles (defun color-dark () (interactive) (global-hl-line-mode 1) (color-theme-deep-blue) (set-face-foreground 'minibuffer-prompt "#9df0f6") (set-face-background 'hl-line "#203e5e")) ;; shell fix (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t) (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) -- 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: trouble setting up emacs
run this script in your .emacs.d directory -- #!/bin/sh git clone https://github.com/technomancy/clojure-mode.git wget -P paredit http://mumble.net/~campbell/emacs/paredit.el wget http://download.savannah.gnu.org/releases/color-theme/color-theme-6.6.0.tar.gz mkdir color-theme tar --strip-components=1 --directory=color-theme -xzf color- theme-6.6.0.tar.gz rm color-theme-6.6.0.tar.gz -- init.el -- (add-to-list 'load-path "~/.emacs.d/") ;; clojure-mode (add-to-list 'load-path "~/.emacs.d/clojure-mode") (require 'clojure-mode) (fset 'compile-and-goto-repl "\C-x\C-s\C-c\C-k\C-c\C-z") (global-set-key (kbd "C-c C-g C-r") 'compile-and-goto-repl) (global-set-key (kbd "C-c C-j C-i") 'clojure-jack-in) ;; paredit (add-to-list 'load-path "~/.emacs.d/paredit") (require 'paredit) (add-hook 'clojure-mode-hook 'enable-paredit-mode) (global-set-key (kbd "M-p M-m e") 'enable-paredit-mode) (global-set-key (kbd "M-p M-m d") 'disable-paredit-mode) ;; color theme (add-to-list 'load-path "~/.emacs.d/color-theme") (require 'color-theme) (eval-after-load "color-theme" '(progn (color-theme-initialize))) -- Start emacs, change current directory (M-x cd) to a leiningen project root and press C-c C-j C-i.It should start clojure repl. You will need swank as dev dependency. :dev-dependencies [[swank-clojure "1.3.1"] [midje "1.1.1"]] hth, Maris On Oct 18, 4:32 am, Bruce Gordon wrote: > I am trying to follow the directions > athttp://dev.clojure.org/display/doc/Getting+Started+with+Emacs. > 1. I want to install the Emacs Starter Kit. The directions > athttp://dev.clojure.org/display/doc/Getting+Started+with+Emacsmention > "GNU Emacs 23 or 24 is recommended", however > https://github.com/technomancy/emacs-starter-kit > says "You'll need Emacs 24". The directions say "precompiled versions > are readily available for Debian-based systems...". I'm using a Debian > based system. so I went tohttp://emacs.naquadah.org/. > a. I executed> wget -q -O -http://emacs.naquadah.org/key.gpg| sudo > apt-key add - > b. I'm now confused as to which version I want: Stable? If so I should > then follow the directions to add 2 lines to /etc/apt/sources.list, > and then what do I do? > > 2. Once I get emacs 24 installed, the directions sort of leave off > with " In both cases, you need to launch a Clojure instance with the > correct classpath settings. This is most commonly done using a build > tool such as Leiningen. For instructions see the Build Tools section > of Getting Started." Going > tohttp://dev.clojure.org/display/doc/Getting+Started > and perusing the Build Tools doesn't explain how to setup and launch a > Clojure instance. I see some explanations > athttp://blog.bensmann.com/setting-up-a-clojure-development-environment > but don't know if that includes some obsolete directions. > > thanks, -Bruce -- 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