Created
May 20, 2015 16:12
-
-
Save obohrer/cf74ef48b2863c009cd6 to your computer and use it in GitHub Desktop.
clj-demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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