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
(System.Reflection.Assembly/LoadWithPartialName "System.Xml.Linq") | |
(ns linq.xml | |
(:import [System.Xml.Linq XDocument XElement XAttribute XNode]) | |
(:import [System.IO MemoryStream StreamReader]) | |
(:import [System.Text Encoding]) | |
(:gen-class)) | |
(defmacro ^:private local-name [node] | |
`(.. ~node Name LocalName)) |
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
#lang racket | |
(provide mycompose1 | |
mycompose) | |
(define-syntax mycompose1 | |
(syntax-rules () | |
((_) values) | |
((_ f1 f2 ...) | |
(lambda arglist (mycompose1$ arglist f1 f2 ...))))) |
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
// spinoza for Nashorn shell (jjs) | |
// original code => https://github.com/kenokabe/spinoza | |
// [usage example] | |
// | |
// > jjs | |
// jjs> load("spnz.js") | |
// ===== spinoza ===== | |
// jjs> world = $(1)(2)(3)(out) | |
// world-> 1,2,3 |
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
#lang racket | |
(define sprite<%> (interface () draw)) | |
(define draw (generic sprite<%> draw)) | |
(define pix% | |
(class* object% (sprite<%>) | |
(super-new) | |
(define/public (draw) | |
'pix-draw))) |
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
#see https://gist.github.com/1023982 (donotuse.py) | |
randomPasswordGenerator = ( | |
lambda repeat, choice, partial, digits, letters: | |
partial(lambda map_join, n: | |
map_join(choice, repeat(digits+letters, n)), | |
lambda f, lis: ''.join(map(f, lis))))( | |
__import__('itertools').repeat, | |
__import__('random').choice, | |
__import__('functools').partial, |
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
(defn drop-start-same | |
[ss] | |
(->> (loop [ss ss] | |
(if (apply = (map first ss)) | |
(recur (map rest ss)) | |
ss)) | |
(map (partial apply str)))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
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
(defn- diff-seq | |
"Returns a lazy seq of numbers in s1 but not in s2. | |
Both of s1 and s2 must be increasing monotonically and infinite sequence." | |
[s1 s2] | |
(let [x1 (first s1), x2 (first s2)] | |
(cond | |
(= x1 x2) (recur (rest s1) (rest s2)) | |
(> x1 x2) (recur s1 (drop-while (partial > x1) s2)) | |
(< x1 x2) (let [[s1a s1b] (split-with (partial > x2) s1)] | |
(lazy-cat s1a (diff-seq s1b s2)))))) |
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
(defn- diff-seq | |
"Returns a lazy seq of numbers in s1 but not in s2. | |
Both of s1 and s2 must be increasing monotonically and infinite sequence." | |
[s1 s2] | |
(let [x1 (first s1), x2 (first s2)] | |
(cond | |
(= x1 x2) (recur (rest s1) (rest s2)) | |
(> x1 x2) (recur s1 (drop-while (partial > x1) s2)) | |
(< x1 x2) (let [[s1a s1b] (split-with (partial > x2) s1)] | |
(lazy-cat s1a (diff-seq s1b s2)))))) |
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
select | |
sys.tables.name as table_name, | |
sys.extended_properties.value as discription, | |
sys.columns.name as column_name, | |
sys.columns.* | |
from sys.columns | |
left outer join sys.tables on (sys.columns.object_id=sys.tables.object_id) | |
left outer join sys.extended_properties on (major_id=sys.columns.object_id and minor_id=sys.columns.column_id) | |
where sys.tables.name is not null | |
order by table_name, sys.columns.column_id |
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
// gmpxx : mpz_class で三項演算子が使えない(解決した) | |
#include <iostream> | |
#include <gmpxx.h> | |
// これなら OK | |
// mpz_class next_collatz(const mpz_class &n){ | |
// if(n % 2 == 0){ | |
// return n >> 1; | |
// }else{ | |
// return n * 3 + 1; |