I'm studing functional programming, but in the different way as I've studied at univerity. So I'm coding some tipycal fp functions in javascript. Now is the bind function.
The code lives here
With this song
while I'm coding
jueves, 26 de noviembre de 2015
miércoles, 4 de noviembre de 2015
Playing with socket.io
More and more javascript is the language that the most of the time I'm writting. Some time ago I've discovered web sockets, so I've been playing with it. The result is a simple chat with socket.io library.
The source of the example code
The code of this example lives in github
Happy hacking
The source of the example code
The code of this example lives in github
Happy hacking
jueves, 8 de octubre de 2015
Setup the current number format
I´ve discovered the new way for setting up numbers in the current country format. I´m from Spain, so the numbers are like 12.345,67.
We can use.
We can use.
var result = parseInt(simpleNumber).toLocaleString('es-ES');
viernes, 28 de agosto de 2015
Discovering Map function in clojure
Here it's the simple function in clojure using map
(map + [1 2 3] [4 5 6] [7 8 9])
then it returns
=> [12 15 18] It's nice an simple ;-)
(map + [1 2 3] [4 5 6] [7 8 9])
then it returns
=> [12 15 18] It's nice an simple ;-)
miércoles, 12 de agosto de 2015
My first function in clojure
This a simple recursive countdown, but in clojure is more interesting. This is the code:
(defn countdown [x] (if (zero? x) (do :blastoff! (println "Zero") ) (do (println x) (recur (dec x)) ) ) )
miércoles, 15 de julio de 2015
Translate simple program from Java to Clojure
In Java:
public static double hypot (double x, double y) {
final double x2 = x * x;
final double y2 = y * y;
return Math.sqrt(x2 + y2);
}
In Clojure
(defn hypot [x y] (let [x2 (* x x) y2 (* y y)] (Math/sqrt (+ x2 y2)) ) )The execution
(println (hypot 2 3))
martes, 14 de julio de 2015
My first code in clojure
I've finished reading Javascript The Good Parts. Yesterday a co-worker said to me that I could learn some functional language, He recommend to me Clojure son I've just started with Programming Clojure and this is my first little program:
When I was writing this little piece of code, I've remember when I was at university and I studied Lisp in IA signature.
(defn average [numbers] (/ (apply + numbers) (count numbers) ) ) (println (average [1 2 3 4 5]) )
When I was writing this little piece of code, I've remember when I was at university and I studied Lisp in IA signature.
Suscribirse a:
Entradas (Atom)