Skip to content

Instantly share code, notes, and snippets.

View uid0130's full-sized avatar

uid0130 uid0130

View GitHub Profile
(require '[incanter.core :as in]
'[incanter.stats :as st]
'[incanter.charts :as ch])
(defn generate-sample-cluster [x y sd n]
(let [generate-by #(st/sample-normal n :mean (+ % (rand 2)) :sd sd)]
(map vector (generate-by x) (generate-by y))))
(defn plot-clusters-with-function [f [fcluster & rclusters :as clusters]]
(let [init-plot (ch/scatter-plot (map first fcluster) (map second fcluster))
@uid0130
uid0130 / find-opt-path.clj
Last active August 29, 2015 14:07
ClojureでSGAによる巡回セールスマン問題
(use '[clojure.core.match :only (match)]
'[clojure.math.numeric-tower :as math])
;;---------------------------------------------------------------
;; profiler
(def profiling-points (ref {}))
(def temp-value (ref []))
(def profile-program true)
(defmacro prof [dist-name s-exp]
;; a simple meta-circular interpreter
;; shift/reset (delimited continuation) implemented
(use util.match)
(define lookup
(lambda (var env exception)
(cond
((null? env)
(exception (string-append
"# error :: could not find the variable > "
;; a simple meta-circular interpreter
;; curried version
(use util.match)
(define lookup
(lambda (var env exception)
(cond
((null? env)
(exception (string-append
"# error :: could not find the variable > "
;; a simple meta-circular interpreter
(use util.match)
(define lookup
(lambda (var env exception)
(cond
((null? env)
(exception (string-append
"# error :: could not find the variable > "
(symbol->string var))))
import java.nio.file.*;
public class FileRead {
public static void main(String args[]) throws Exception{
System.out.println(new String(Files.readAllBytes(Paths.get("src/short.txt")), "UTF-8"));
}
}
(require 'generic-x)
(defun list-interleave (ls res inserting)
(cond
((not ls) (reverse res))
((not res) (list-interleave (cdr ls) (cons (car ls) res) inserting))
(t (list-interleave
(cdr ls)
(cons (car ls) (cons inserting res))
inserting))))