A tutorial on learning Clojure vector

Vector plays a very special role in Clojure, its one of the most primitive data strucutre in Clojure. Its impossible to master Clojure without a very deep understanding about vector.

The concept of vector exist almost all main stream languages, its the simplest compound data structure. In dynamic language like PHP and Javascript, vector is represented with associate array, and its no different with a map. We should careful about the terminology here, in PHP and Javascript, the name array should be vector, even they call it array. Array should be fixed length, an vector is much like the vector in C++ STL or Java's ArrayList, its dynamically grow.

The concept of vector exist almost all main stream languages, its the simplest compound data structure. In dynamic language like PHP and Javascript, vector is represented with associate array, and .

Clojure optional arguments and argument default value

Optional arguments of function is a nice feature and many programming language support it. For example in VB.NET

This is how to define optional arguments and its default value in VB.NET. If we put the optional arguments in the end of parameter list.

How to save Slideshare presentation as pdf file with Clojure and clj-pdf library

Clojure is a dynamical functional language runs on JVM. Its also a modern LISP with elegant syntax and powerful data structures. And whats more, Clojure is fully inter operatable with JAVA, all the JAVA libraries are readily available.

This post introduce you an easy way to save a slideshare as one pdf file with Clojure.

Why waitFor method in java.lang.Process hang

In last post Executing shell command in Clojure REPL. I present a function that can execute shell command from Clojure REPL.

Well, the script will work in most situations but you will find it not work in some edge cases because there are something missing in our implementation.

Executing shell command in Clojure REPL

When you are working in Clojure REPL and want do something in shell. How to do it ? Most of the time I will Ctrl + C break from REPL and switch back after shell interaction.

And its inconvenient, and most importantly, if I already defined something in REPL , I have to restore them after switching back.

Clojure map and mapv

I was reading The Joy Of Clojure the first edition and looking at chapter 7, and experimenting the A* path finding code.

And it gives me this error

The magic of Clojure trampoline function

The trampoline function is Clojure's way to explicitly optimize mutual recursion.

A quick Wikipedia check you will get the idea, but lets just get an simple overview right here.

Understand Clojure recur and tail recursion optimization

Or naive recursion, linear recursion, mundane recursion. They are semantically equivalent to iteration. But recursive version consumes more memory. At each loop, recursive function call creates a new stack frame and all the local variables have a new copy , by doing this, the recursive version don't have to mutate anything, the cost is stack frame consumption.

Why the cons car cdr are missing in Clojure

was playing with Clojure REPL and when I try to use cons car that existed in LISP ... to resolve symbol: car in this context, compiling:(NO_SOURCE_PATH:6:1) user=> (cons 1 2 ... :505) user=> Looks like these functions are different in Clojure. Use cons in Clojure ... 1 '(1 2 3 4)) (1) user=> (car '(1 2 3 4 )) CompilerException java.lang.RuntimeException: Unable
Previous Page 1 ... 5 6