A Lightning talk
@NagarajanFs
Anyone could learn Lisp in one day, except that if they already knew Fortran, it would take three days.
Full stack develolper
Fiddle with Js
Sr. Software Engineer @ Snapwiz. Inc.,
Amateur Harmonica Player
@NagarajanFs
Tell others what to do
https://github.com/oneto018
function add(a,b){
return a+b;
}
//or
const add =
(a, b) => a+b;
add(3,5)(defn add
[a b]
(+ a b))
(add 3 5)a + 5;
(a+b)-c;
f1(f2(8,b),10)(+ a 5)
(- (+ a b) c)
; or
(-> (+ a b)
(- c))
(f1 (f2 8 b))
; or
(-> (f2 8 b)
(f1 10))const users = [{ name: "name1", age: 20 },
{ name: "name2", age: 30 }];
(def users [{:name "name1" :age 20}
{:name "name2" :age 30}])var x = 5(def x 5)const user1Age = users[0].age
//or with lodash
const user1Age = _.get(users,[0,"age"])(def user1-age
(get-in users [0 :age]))// both of this will mutate the object
users[0].age = 21
//or with lodash
_.set(users,[0,"age"],21);doesn't update existing and returns the new data
(assoc-in users [0 :age] 21)// this will mutate the object
_.update(users,[0,"age"],(x) => x+1)(update-in users [0 :age] inc) ; or
(update-in users [0 :age] #(+ % 1))We need to way to identify(reference) this changing State in our programs. We can call that Identity
We need to way to identify(reference) this changing State in our programs. We can call that Identity
(defonce users (atom [{:name "name1" :age 20}
{:name "name2" :age 30}]))
(defn increment-users-age! [users index]
(swap! users update-in [index :age] inc)
(println "users currently before incrementing" @users)
(increment-users-age! users 0)
(println "users currently after incrementing" @users)