This file contains hidden or 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
user> (iter {for x from 1 to 10} | |
{reduce x by conj initially [] into odds if (odd? x)} | |
{reduce x by conj initially [] into evens if (even? x)} | |
{sum x into sum-odds if (odd? x)} | |
{sum x into sum-evens if (even? x)} | |
{returning {:evens evens | |
:odds odds | |
:sum-odds sum-odds | |
:sum-evens sum-evens}}) | |
{:evens [2 4 6 8 10], :odds [1 3 5 7 9], :sum-odds 25, :sum-evens 30} |
This file contains hidden or 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
;; Just for fun! | |
;; If Clojure were like Python, I could have used (asdf **{:a 1 :b 2 :c 3}) when calling asdf | |
user> (defn asdf | |
[& {:keys [a b c]}] | |
[a b c]) | |
#'user/asdf | |
user> (defmacro call** | |
[func kw-map] | |
`(~func ~@(mapcat identity kw-map))) |
This file contains hidden or 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
user> (group-by #(cond (and (> % 10) | |
(< % 20)) | |
:between-10-20 | |
(and (> % 30) | |
(< % 40)) | |
:between-30-40 | |
(and (> % 90) | |
(< % 100)) |
This file contains hidden or 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
(defproject scratch "1.0.0-SNAPSHOT" | |
:description "FIXME: write description" | |
;; http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.clojure%22 | |
;; http://dev.clojure.org/display/doc/Clojure+Contrib | |
;; http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go | |
:dependencies [[org.clojure/clojure "1.3.0"] | |
[org.mongodb/mongo-java-driver "2.6.3"] | |
[postgresql/postgresql "9.0-801.jdbc4"] | |
[mysql/mysql-connector-java "5.1.18"] | |
[org.apache.lucene/lucene-core "3.4.0"] |
This file contains hidden or 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
(defproject scratch "1.0.0-SNAPSHOT" | |
:description "FIXME: write description" | |
;; http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.clojure%22 | |
;; http://dev.clojure.org/display/doc/Clojure+Contrib | |
;; http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go | |
:dependencies [[org.clojure/clojure "1.3.0"] | |
[org.mongodb/mongo-java-driver "2.6.3"] | |
[postgresql/postgresql "9.0-801.jdbc4"] | |
[mysql/mysql-connector-java "5.1.18"] | |
[org.apache.lucene/lucene-core "3.4.0"] |
This file contains hidden or 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
;;; http://www.xach.com/lisp/buildapp/ | |
;;; buildapp --output hello-world --asdf-path ~/asds/ --load hello-world.lisp --entry main | |
;;; nipra@unlambda:~/Projects/CL$ ./hello-world | |
(in-package :cl-user) | |
(defun main (argv) | |
(declare (ignore argv)) | |
(format t "Hello World!~%")) |
This file contains hidden or 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
scratch> (s/deserialize "some data" :bytes) | |
; Evaluation aborted. | |
scratch> (s/deserialize "{\"language\":\"Clojure\",\"library\":\"serialism\",\"authors\":[\"Michael\"]}" | |
:json) | |
; Evaluation aborted. |
This file contains hidden or 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
(let [f1 (PrefixFilter. (hb/to-bytes "0 "))] | |
(hb/with-table [table (hb/table "foo_bar_table")] | |
(hb/with-scanner [scanner (hb/scan table | |
:filter f1 | |
:caching 1000)] | |
(loop [n 0] | |
(if (seq (.next scanner 1000)) | |
(recur (+ n (count (.next scanner 1000)))) | |
n))))) |
This file contains hidden or 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
# Installing CDH4 on a Single Linux Node in Pseudo-distributed Mode | |
# https://ccp.cloudera.com/display/CDH4DOC/Installing+CDH4+on+a+Single+Linux+Node+in+Pseudo-distributed+Mode | |
# Installing CDH4 with MRv1 on a Single Linux Node in Pseudo-distributed mode | |
# On Ubuntu and other Debian systems | |
nipra@lambda:Downloads$ wget -cv http://archive.cloudera.com/cdh4/one-click-install/precise/amd64/cdh4-repository_1.0_all.deb | |
nipra@lambda:Downloads$ sudo dpkg -i cdh4-repository_1.0_all.deb # Adds /etc/apt/sources.list.d/cloudera-cdh4.list ?? | |
nipra@lambda:Downloads$ dpkg -L cdh4-repository # To view the files on Ubuntu systems | |
# Install CDH4 |
This file contains hidden or 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
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<!-- Replace the group ID with your group ID --> | |
<groupId>com.mycompany.hadoopproject</groupId> | |
<!-- Replace the artifact ID with the name of your project --> | |
<artifactId>my-hadoop-project</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> |