This file contains 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
;; hyone's solution to Pascal's Triangle | |
;; https://4clojure.com/problem/97 | |
(fn [n] (nth (iterate #(vec (map + (conj % 0) (cons 0 %))) '[1]) (dec n))) |
This file contains 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
# 安直にやる | |
doors1 = (1..100).inject([false] * 100) {|a,p| | |
a.each_with_index.map {|st,i| (i+1) % p == 0 ? !st : st } | |
}.map {|b| b ? :open : :close } | |
# 平方数だけが最終的 open になる、という性質を使う | |
doors2 = (1..100).map {|i| | |
root = Math.sqrt(i) | |
root == root.to_i ? :open : :close | |
} |
This file contains 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
(require 'elscreen) | |
(defun elscreen-cycle (count &optional previous) | |
"Switch the next/previous screen cyclically by count." | |
(cond | |
((elscreen-one-screen-p) | |
(elscreen-message | |
(format "You cannot escape from screen %d!" | |
(elscreen-get-current-screen)))) | |
(t |
This file contains 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
type figure = | |
Point | |
| Circle of float | |
| Rectangle of float * float | |
| Square of float;; | |
type 'a with_location = { loc_x: float; loc_y: float; body: 'a };; | |
let diff x y = abs_float (x -. y) |
This file contains 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
;; From https://github.com/overtone/live-coding-emacs/blob/master/lib/durendal/durendal.el | |
(defun clojure-slime-repl-fix-syntax () | |
(modify-syntax-entry ?\{ "(}") | |
(modify-syntax-entry ?\} "){") | |
(modify-syntax-entry ?\[ "(]") | |
(modify-syntax-entry ?\] ")[") | |
(modify-syntax-entry ?~ "' ") | |
(modify-syntax-entry ?, " ") | |
(modify-syntax-entry ?^ "'") |
This file contains 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 prove on *.t file | |
(quickrun-add-command "perl/test" | |
'((:command . "prove") | |
(:exec . "%c -v %s") | |
(:description . "Run Perl Test script"))) | |
(add-to-list 'quickrun-file-alist '("\\.t$" . "perl/test")) |
This file contains 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
(defadvice quickrun/apply-outputter (after quickrun/fix-scroll-buffer activate) | |
(recenter)) |
This file contains 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 v5.14; | |
use warnings; | |
sub hoge { | |
say do { | |
given (wantarray) { | |
when (undef) { "void" } | |
when (0) { "scalar" } | |
when (1) { "list" } | |
} |
This file contains 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 async-test1 "1.0.0-SNAPSHOT" | |
;; :description "FIXME: write description" | |
;; :dependencies [[org.clojure/clojure "1.3.0"] | |
;; [http.async.client "0.4.0"]] | |
;; :dev-dependencies [[swank-clojure "1.3.4"]]) | |
(ns async-test1.core | |
(:require [http.async.client :as client] | |
[http.async.client.request :as request])) |
This file contains 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 async-test2 "1.0.0-SNAPSHOT" | |
;; :description "FIXME: write description" | |
;; :dependencies [[org.clojure/clojure "1.3.0"] | |
;; [aleph "0.2.1-alpha1"]]) | |
(ns async-test2.core | |
(:use lamina.core | |
aleph.http)) |