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 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))))) |
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 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 |
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
; 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. |
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
{} |
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
;; 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"))) |