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
;; Take k-th product while n!(n-1)!...(n-k+1)!...2!1! | |
;; | |
(map (fn [x] (reduce * x)) (take 10 (iterate rest (range 10 0 -1)))) | |
;; (3628800 362880 40320 5040 720 120 24 6 2 1) | |
(reduce *' (map (fn [x] (reduce *' x)) (take 10 (iterate rest (range 10 0 -1))))) | |
;; 6658606584104736522240000000N |
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
;; Leiningen 2.3.2 | |
;; Clojure 1.5.1 | |
;; REPL | |
;; | |
(defn maplist [f coll] (map #(apply f %) (take (count coll) (iterate rest coll)))) | |
(maplist min (range 10)) | |
;; (0 1 2 3 4 5 6 7 8 9) | |
(maplist max (range 10)) | |
;; (9 9 9 9 9 9 9 9 9 9) | |
(maplist * (range 1 11)) |
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
package org.coursera.algs4partII002.perf; | |
import org.junit.Test; | |
import java.io.BufferedInputStream; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.util.Scanner; | |
import java.util.StringTokenizer; |
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
(defun insert-textual-timestamp-in-diary () | |
;; Set timestamp insert function. This function comes from | |
;; http://www.patd.net/~ciggieposeur/other/startup.el | |
;; RFC 3339 and ISO 8601 | |
(interactive "*") | |
(insert | |
(concat "[" | |
(format-time-string "%Y-%m-%dT%T%z" (current-time)) | |
"] "))) | |
(global-set-key (kbd "C-c 1 `") 'insert-textual-timestamp-in-diary) |
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
(use 'clojure.string) | |
(defn gen-rnd-idx-seq [s] | |
(let [ordered-idx (range (count s)) | |
randomed-idx (map #(rand-int %) ordered-idx) | |
arrayed-s (into-array s)] | |
(join (reduce #(let [foo-idx (first %2) | |
bar-idx (last %2) | |
foo (nth arrayed-s foo-idx) | |
bar (nth arrayed-s bar-idx)] |
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
find . -type f -regex '.*\ .*' | awk '{gsub(/\(/,"\\(",$0);gsub(/\)/,"\\)",$0);gsub(/\ /,"\\ ",$0);orig_fname=$0;gsub(/ /,".",$0);system("mv -v " orig_fname " " $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
#!/usr/bin/python | |
import os | |
import sys | |
import getopt | |
import re | |
import os.path | |
def main(): |
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
(defun distl (m N) | |
(cond | |
((null N) nil) | |
(t (cons (list m (car N)) | |
(distl m (cdr N)))))) | |
(print (distl 'b '(x y z))) | |
(defun cartesian (M N) | |
(cond | |
((null M) 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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; golang mode | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(add-to-list 'load-path "C:/go/misc/emacs/") | |
(require 'go-mode-load) |
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
CXX = i686-pc-mingw32-g++ | |
CXXFLAGS = -Wall | |
CXXDEBUGFLAG = -g | |
CXXOPTFLAG = -O3 | |
CXX0XFLAG = -std=c++0x | |
CXXLINKFLAG = -static | |
BINS = cxx0x-address | |
all: $(BINS) |