# Why these two, together?

Clojure, a dialect of Lisp, is best suited to be a programmed in the legendary Emacs editor, which also happens to be programmed in Lisp. Coincidence? I think not!
So, here I’m basically going to log my journey as I start learning the Clojure programming language in the Emacs editor. So this blog is going to witness Souvik Haldar learning two things at once :D

# Basics steps for beginning a CLojure project

### Prerequisites

i) Install Leiningen.
ii) Setup emacs with cider and other required packages, follow this
(run `M-x load-file` `RET` `<path-to-init.el>` if emacs doesn’t look right)

### Steps

i) Create the project using `lein new app project_euler` (Since we are going to solve euler’s problems for learning)
ii) Open emacs
iii) `C-x C-f` (then locate the `core.clj` file inside `project_euler` directory)
iv) Fire up the REPL by `M-x cider-jack-in`
v) Save the file by `C-x C-s` then compile it by `C-c C-k`.
vi) Switch to the REPL buffer by `C-o`. (or, you can see all running buffers by `C-x b` then `RET` the buffer in which REPL is running) vii) Now you can run the desired function by running it the REPL buffer by `(<function-name> <arg>)`

## Example program written in Clojure

Question: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

```(defn fibonacci [sum first second]
(if (>= sum 4000000)
sum
(do
(if (even? second)
(recur (+ sum second) second (+ first second))
(recur sum second (+ first second))))))```

I’m currently solving Project Euler to learn to practice while learning. The solved problems can be found here. Happy Coding!
{"ft_lang_label":"__label__en","ft_lang_prob":0.87557644,"math_prob":0.52954906,"size":1824,"snap":"2019-51-2020-05","text_gpt3_token_len":473,"char_repetition_ratio":0.104945056,"word_repetition_ratio":0.0,"special_character_ratio":0.25274122,"punctuation_ratio":0.101604275,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9768917,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-12-07T19:04:28Z\",\"WARC-Record-ID\":\"<urn:uuid:589080fe-fc09-45e1-94b3-3fc0ebd6422e>\",\"Content-Length\":\"7641\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:266737c4-00fa-4a97-bed9-87daaf5a3fc2>\",\"WARC-Concurrent-To\":\"<urn:uuid:6c8589bb-edf6-4dbf-80a9-15cf7caa3e15>\",\"WARC-IP-Address\":\"68.183.86.2\",\"WARC-Target-URI\":\"http://souvikhaldar.info/programming/emacs_clojure/\",\"WARC-Payload-Digest\":\"sha1:OZDB2253KHZGJPUAIU5FPYNN6MLU3RCS\",\"WARC-Block-Digest\":\"sha1:CN6RTFKKIGIT7ZIH55IPJPIMCWTUWXKC\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-51/CC-MAIN-2019-51_segments_1575540501887.27_warc_CC-MAIN-20191207183439-20191207211439-00476.warc.gz\"}"}