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
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
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
; Church Numerals in Clojure | |
; | |
; Church numerals use anonymous functions to represent numbers. | |
; | |
; ((zero f) x) -- returns x | |
; ((one f) x) -- return (f x) | |
; ((two f) x) -- return (f (f x)) | |
; ... | |
(def zero (fn [f] (fn [x] x))) |
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
;;; ghoseb.el -- My customisations in addition to ESK | |
;;; Author: Baishampayan Ghose <[email protected]> | |
;;; Time-stamp: "2009-08-01 01:44:30 ghoseb" | |
(require 'cl) | |
;;; ---------------------- | |
;;; General customisations | |
;;; ---------------------- | |
(set-scroll-bar-mode 'nil) |
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
(ns redis-memo | |
(:require redis) | |
(:import (java.net URLEncoder))) | |
;; -------------------------------------------------------------------------------- | |
;; Default connection params | |
;; -------------------------------------------------------------------------------- | |
(def memo-server {:host "localhost" :port 6379 :db 14}) |
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
# log4j.properties | |
log4j.rootLogger = DEBUG, standard | |
log4j.appender.standard = org.apache.log4j.RollingFileAppender | |
log4j.appender.standard.File = logs/project.log | |
log4j.appender.standard.MaxFileSize=1MB | |
log4j.appender.standard.MaxBackupIndex=1 | |
log4j.appender.standard.layout = org.apache.log4j.PatternLayout |
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
(defn tests [] | |
[{:name 'suiteA | |
:total 3 | |
:passed (promise) | |
:failed (promise) | |
:success (promise) | |
:tests [{:name 'testA :success (promise)} | |
{:name 'testB :success (promise)} | |
{:name 'testC :success (promise)}]} | |
{:name 'suiteB |
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
(defn tests [] | |
[{:name 'suiteA | |
:total 3 | |
:tests [{:name 'testA} | |
{:name 'testB} | |
{:name 'testC}]} | |
{:name 'suiteB | |
:total 3 | |
:tests [{:name 'testD} | |
{:name 'testE} |
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
;; | |
;; NS CHEATSHEET | |
;; | |
;; * :require makes functions available with a namespace prefix | |
;; and optionally can refer functions to the current ns. | |
;; | |
;; * :import refers Java classes to the current namespace. | |
;; | |
;; * :refer-clojure affects availability of built-in (clojure.core) | |
;; functions. |
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
;;; accounts.clj -- Accounts -*- Clojure -*- | |
;;; Time-stamp: "2010-05-04 11:17:53 ghoseb" | |
;;; Author: Baishampayan Ghose <[email protected]> | |
(ns accounts) | |
(def *min-bal* 500) | |
(defstruct account | |
:name |
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
(ns test) | |
(defn try-times | |
"Try executing a thunk `retries` times." | |
[retries thunk] | |
(if-let [res (try | |
[(thunk)] | |
(catch Exception e ; can be any exception | |
(when (zero? retries) | |
(throw e))))] |
OlderNewer