Skip to content

Instantly share code, notes, and snippets.

View siscia's full-sized avatar

Simone Mosciatti siscia

View GitHub Profile
@siscia
siscia / json-objectid.md
Created August 28, 2014 16:57
json-objectid
layout title description category tags
post
Manage (Mongodb's) ObjectId and json
clojure
mongo
mongodb
rest
REST

I was writing yet another REST interface in Clojure + MongoDB (this is the last time) and if you have ever mixed this technology there is a little issues that raise every single time.

layout title description category tags
post
Manage (Mongodb's) ObjectId and json
clojure
mongo
mongodb
rest
REST

I was writing yet another REST interface in Clojure + MongoDB (this is the last time) and if you have ever mixed this technology there is a little issues that raise every single time.

layout title description category tags
post
Manage (Mongodb's) ObjectId and json
clojure
mongo
mongodb
rest
REST

I was writing yet another REST interface in Clojure + MongoDB (this is the last time) and if you have ever mixed this technology there is a little issue that raises every single time.

Maps are fundamental data structures in any clojure program.

They are extremely fast, simple to reason about and very handy. Declaration of maps

As you may know, maps are a correlation between two clojure 'object' and are defined as so:

{% highlight clojure %} {"key_a" "value_a" "key_b" (fn [b] "value_b")

@siscia
siscia / ruby-clojure
Last active August 29, 2015 14:06 — forked from mikel99/ruby-clojure
ruby/clojure

As I promise I am keep going my previous article, this time I will focus on creating maps.

Let's start exploring the function that return maps.

hash-map

How you may guess by yourself hash-map takes as input an even number of argument and return a map.

{% highlight clojure %} user> (hash-map :key :val :a :b)

user> (import 'java.util.Date)
java.util.Date
user> (def now (Date.))
#'user/now
user> now
#inst "2014-09-17T03:14:13.821-00:00"
user> (def bean-map (bean now))
#'user/bean-map
user> bean-map
{:day 3, :date 17, :time 1410923653821, :month 8, :seconds 13, :year 114, :class java.util.Date, :timezoneOffset -120, :hours 5, :minutes 14}
layout title description category tags
post
Create Clojure Map, advanced methods, PART 2

{% include JB/setup %}

Let's continue our journey of functions that return maps.

(t/cf
(t/ann-form
(fn [a b]
(merge a b))
[(t/HMap :mandatory {:a String}) (t/HMap :mandatory {:b String}) -> (t/HMap :mandatory {:a String :b String})]))
Error in user YAML: (<unknown>): did not find expected ',' or ']' while parsing a flow sequence at line 5 column 7
---
layout: post
title: "Read clojure map values 1/2"
description: ""
category: programming
tags: [clojure, map, read map, read, get, get-in, contains?, find]
excerpt: "First chapter about how to read values from a clojure map: get, get-in, contains?, find ."
---

{% include JB/setup %}