Hello,

I have a some comments (on comments and more :))

First this
(comment ..... )

There are diffrent kind ofs comments. If you just want to note
something you can do ; but mabey you want to have a example how to use
something in your Code then use (comment ....).

With "defn" you creat a new function with a name.

First switch the order of your function implementation

(defn -main
 ([] (-main "world"))
 ([greetee]
    (println (str "Hello " greetee "!"))))

What you are doing is implementing the -main method twise one for no
arguments once for one argument ([] and [greetee])

This is a handy because you can make an easy and fast default
implementation. An other way would be doing it like this

(defn -main
 ([] (println "Hello world"))
 ([greetee]
    (println (str "Hello " greetee "!"))))

But if you want to change something (Hello to helo or something) you
would have to do this two times. So you just call your second
implementation ([greetee] ...... ) with "world". So a change got
something in ([greetee] ....) works for both implementations.

So what does (str "Hello " greetee) do?

Lets say you call -main like this (-main "nickik") then the greetee
variable is a string. With (str ...) you make one string out of the
arguments.

(str "Hallo " "nickik") --> "Hallo nickik"

than that is printed.

If you call -main like this (-main 75) is will work because 75 will be
converted to "75".

Because you new some additional information. In most langauges you
would have to tell the compiler what greetee is ( int or string ....)
these are what we call static languages but in clojure you dont have
to. That is wath makes a language dynamic. So you can pass in
everything that can be converted to a string.

Interessting that you learn programming with clojure. I had to unlearn
so many bad stuff that I was used to.

If you want to use a lot of clojure you should learn git a liddle bit
(there is a free book "Pro Git") most of clojure stuff people do is on
github.org

You can try the laprepl http://github.com/relevance/labrepl its made
to help getting started

Some links for you to finish this up some are probebly hard for you:
http://clojure.blip.tv/  <-- videos about clojure (most of them from
rich himself if  you are hot for more surf infoq.com)

The book that  David Nolen mentiond:
http://mitpress.mit.edu/sicp/full-text/book/book.html and Videos to
help you learn you can found here:
>From MIT 1986: http://www.youtube.com/watch?v=2Op3QLzMgSY  and the
next 20 vids but you can download them too just google them.

Or if you like  Berkeley more http://www.youtube.com/watch?v=zmYqShvVDh4

More on Programming in (its in java but it starts at lvl absolute
ZERO)
http://www.youtube.com/user/stanforduniversity?blend=2&ob=4#g/c/84A56BC7F4A1F852

But i recommend stike with the SICP book and courses they are harder
but its worth it. Specaly if you like clojure.

Sorry for tipping errors

Great

On Jun 11, 5:47 pm, Jared <tri...@gmail.com> wrote:
> Hi everyone,
>
> I'm 100% new to LISP, 95% new to Java, and 90% new to programming in
> general. Where and how would you recommend learning Clojure? I'm
> planning on buying Programming Clojure, but until then what would you
> suggest?
>
> I got Netbeans working with Clojure and the default template is this:
>
> (comment
> Sample clojure source file
> )
> (ns com.yourcompany.defpackage
>     (:gen-class))
>
> (defn -main
>     ([greetee]
>   (println (str "Hello " greetee "!")))
>   ([] (-main "world")))
>
> It ran and printed "Hello world!". Can anyone explain to me in detail
> what each statement means. I'm particularly confused by:
>
> (comment
> Sample clojure source file
> )
>
> I thought all comments began with ; ? I understand what println does
> and that's it.
>
> Thanks in advance everyone.

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

Reply via email to