Skip to content

Instantly share code, notes, and snippets.

@kohyama
Created March 7, 2014 08:59
Show Gist options
  • Save kohyama/9408009 to your computer and use it in GitHub Desktop.
Save kohyama/9408009 to your computer and use it in GitHub Desktop.
Ntmux を用いたマルチリンガル開発 ref: http://qiita.com/kohyama/items/d2399fd1d58cd8aec72a
% ntmux 5000 irb
irb(main):001:0>
irb(main):001:0> (1..10).map{|x| x * x}
=> [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
function range(s, n) {
var r = [], i;
for (i = s; i < n; i++)
r.push(i);
return r;
}
((function(x){return x * x;})(
range(1, 101).reduce(function(a, b){return a + b;}))
-
range(1, 101).map(function(x){return x * x;}
).reduce(function(a, b){return a + b;}))
let range s e =
let rec f r s e = if s = e then r else f (s::r) (s + 1) e
in List.rev @@ f [] s e;;
let foldl1 f xs = match xs with x::xs -> List.fold_left (+) x xs;;
((fun x -> x * x) @@ foldl1 (+) @@ range 1 101)
- (foldl1 (+) @@ List.map (fun x -> x * x) @@ range 1 101);;
(defun range (s e)
(loop for i from s to (1- e) collect i))
(- (funcall (lambda (x) (* x x)) (apply #'+ (range 1 101)))
(apply #'+ (mapcar #'(lambda (x) (* x x)) (range 1 101))))
((lambda x: x * x)(reduce(lambda a, b: a + b, range(1, 101)))
- reduce(lambda a, b: a + b, map(lambda x: x * x, range(1, 101))))
function! Send(host, port, msg)
python <<EOF
import vim
import socket
cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
cs.connect((vim.eval('a:host'), int(vim.eval('a:port'))))
cs.sendall(vim.eval('a:msg'))
cs.close()
EOF
endfunction
function! GetSelected()
let tmp = @@
silent normal gvy
let selected = @@
let @@ = tmp
return selected
endfunction
command! -nargs=1 PSend call Send('localhost', <args>, GetSelected())
vnoremap cp <Esc>:PSend port<CR>
(defun range (s e)
(loop for i from s to (1- e) collect i))
(- (funcall (lambda (x) (* x x)) (apply #'+ (range 1 101)))
(apply #'+ (mapcar #'(lambda (x) (* x x)) (range 1 101))))
(- (#(* % %) (apply + (range 1 101)))
(apply + (map #(* % %) (range 1 101))))
((\x -> x * x) $ foldl1 (+) [1..100])
- (foldl1 (+) $ map (\x -> x * x) [1..100])
function range(s, n) {
var r = [], i;
for (i = s; i < n; i++)
r.push(i);
return r;
}
((function(x){return x * x;})(
range(1, 101).reduce(function(a, b){return a + b;}))
-
range(1, 101).map(function(x){return x * x;}
).reduce(function(a, b){return a + b;}))
let range s e =
let rec f r s e = if s = e then r else f (s::r) (s + 1) e
in List.rev @@ f [] s e;;
let foldl1 f xs = match xs with x::xs -> List.fold_left (+) x xs;;
((fun x -> x * x) @@ foldl1 (+) @@ range 1 101)
- (foldl1 (+) @@ List.map (fun x -> x * x) @@ range 1 101);;
((lambda x: x * x)(reduce(lambda a, b: a + b, range(1, 101)))
- reduce(lambda a, b: a + b, map(lambda x: x * x, range(1, 101))))
(1..100).inject(:+) ** 2 \
- (1..100).map{|x| x * x}.inject(:+)
(((x:Int) => x * x)(List.range(1, 101).reduceLeft(_ + _))
- List.range(1, 101).map(x => x * x).reduceLeft(_ + _));
(use srfi-1)
(define (fold1 f s) (fold f (car s) (cdr s)))
(- ((lambda (x) (* x x)) (fold1 + (iota 100 1)))
(fold1 + (map (lambda (x) (* x x)) (iota 100 1))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment