Skip to content

Instantly share code, notes, and snippets.

View terry3's full-sized avatar

Tengfei Guo terry3

View GitHub Profile
@terry3
terry3 / gla-temp.clj
Created January 20, 2017 10:06
git lang ana core.clj
(ns git-lang-ana.core
(:require [clj-http.client :as client])
(:gen-class))
(import '(java.util TimerTask Timer))
(defn every [time f & args]
(let [task (proxy [TimerTask] []
(run [] (apply f args)))]
(. (new Timer) (schedule task 0 (* 1000 time)))))
@terry3
terry3 / n-comp.clj
Created January 19, 2017 07:29
n comp implementation in clojure
(defn n-comp
[& fs]
(fn [& args]
(reduce #(%2 %1)
(apply (last fs) args)
(rest (reverse fs)))))
((n-comp inc inc inc inc inc ) 1) ; output 6
@terry3
terry3 / snake.clj
Created January 17, 2017 09:14
Snake game in clojure v1.8
; This is a Swing-based game where the arrow keys to guide
; a snake to apples. Each time the snake eats an apple it
; grows and a new apple appears in a random location.
; If the head of the snake hits its body, you lose.
; If the snake grows to a length of 10, you win.
; In either case the game starts over with a new, baby snake.
;
; This was originally written by Abhishek Reddy.
; Mark Volkmann rewrote it in an attempt to make it easier to understand.
@terry3
terry3 / sync hyperterm config
Created October 20, 2016 10:15
sync hyperterm config
{}
@terry3
terry3 / gist:8c91acbf044ef7e28fd6
Last active March 3, 2016 09:28
The recursive implement of get n-th element in list
;; The recursive implement of get n-th element in list
(defun get-n (x y)
(if (eql x 0)
(car y)
(get-n (- x 1) (cdr y))))
(write-line (get-n 0 '("a" "b" "c" "d" "e")))
(write-line (get-n 1 '("a" "b" "c" "d" "e")))
(write-line (get-n 2 '("a" "b" "c" "d" "e")))
(write-line (get-n 3 '("a" "b" "c" "d" "e")))