Skip to content

Instantly share code, notes, and snippets.

@obohrer
Created May 20, 2015 16:12
Show Gist options
  • Save obohrer/cf74ef48b2863c009cd6 to your computer and use it in GitHub Desktop.
Save obohrer/cf74ef48b2863c009cd6 to your computer and use it in GitHub Desktop.
clj-demo
(ns clj-demo.core
(:require [cheshire.core :as json]))
(foo :toto)
(defn factoriel
[n]
(->> n range (map inc) (reduce *)))
(factoriel 3)
(map inc (range 2))
(def notif
{:aps {:body "A body"
:title "A title"}
:badge 1
:sound "default"})
(:sound {})
(println notif)
(println (json/generate-string notif))
(:a (json/parse-string "{\"a\":1}" true))
(update-in notif [:badge] inc)
(-> notif
(update-in [:badge] inc)
(dissoc :sound))
(def users
[{:name "Daniel" :meals [:beef :pork :chicken]}
{:name "Matthieu" :meals [:chicken :crocodile]}
{:name "Olivier" :meals []}])
(->> users
(filter #(= (:name %) "Daniel"))
first)
(->> users
(filter (comp (partial = "Daniel") :name)))
(->> users
(remove #(empty? (:meals %))))
(->> users
(filter #(empty? (:meals %))))
(->> users
(map :meals)
flatten
distinct)
(->> users
(map :meals)
flatten
distinct
count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment