Created
          March 7, 2014 08:59 
        
      - 
      
- 
        Save kohyama/9408009 to your computer and use it in GitHub Desktop. 
    Ntmux を用いたマルチリンガル開発 ref: http://qiita.com/kohyama/items/d2399fd1d58cd8aec72a
  
        
  
    
      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
    
  
  
    
  | % ntmux 5000 irb | |
| irb(main):001:0> | 
  
    
      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
    
  
  
    
  | irb(main):001:0> (1..10).map{|x| x * x} | |
| => [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] | 
  
    
      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
    
  
  
    
  | 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;})) | 
  
    
      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
    
  
  
    
  | 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);; | 
  
    
      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
    
  
  
    
  | (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)))) | 
  
    
      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
    
  
  
    
  | ((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)))) | 
  
    
      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
    
  
  
    
  | 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> | 
  
    
      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
    
  
  
    
  | (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)))) | 
  
    
      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
    
  
  
    
  | (- (#(* % %) (apply + (range 1 101))) | |
| (apply + (map #(* % %) (range 1 101)))) | 
  
    
      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
    
  
  
    
  | ((\x -> x * x) $ foldl1 (+) [1..100]) | |
| - (foldl1 (+) $ map (\x -> x * x) [1..100]) | 
  
    
      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
    
  
  
    
  | 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;})) | 
  
    
      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
    
  
  
    
  | 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);; | 
  
    
      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
    
  
  
    
  | ((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)))) | 
  
    
      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
    
  
  
    
  | (1..100).inject(:+) ** 2 \ | |
| - (1..100).map{|x| x * x}.inject(:+) | 
  
    
      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
    
  
  
    
  | (((x:Int) => x * x)(List.range(1, 101).reduceLeft(_ + _)) | |
| - List.range(1, 101).map(x => x * x).reduceLeft(_ + _)); | 
  
    
      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
    
  
  
    
  | (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