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
(display "Hello World!\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
(map (lambda (x) (* x x)) (list 1 2 3)) ;=> (1 4 9) |
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
(reduce + 0 (map (lambda (e) (* e 2)) (list 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
# without for | |
Array.new(50) {|n| 2 * n + 1}.inject(:+) | |
# with for | |
s = 0 | |
for i in (0..49) do | |
s = s + lambda{|n| 2 * n + 1}.call(i) | |
end | |
s |
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
(define (make-list proc st en) | |
(cond ((= st en) (cons (proc en) '())) | |
(else (cons (proc st) | |
(make-list proc | |
(+ st 1) | |
en))))) | |
(reduce + 0 (make-list (lambda (n) (+ 1 (* 2 n))) 0 49)) |
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
#include <stdio.h> | |
int sum_to_100(void); | |
int product_to_10(void); | |
int main (int argc, const char * argv[]) | |
{ | |
sum_to_100(); | |
product_to_10(); | |
return 0; |
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
(define (enum-nums proc init limit) | |
(if (> init limit) | |
'() | |
(cons init (enum-nums proc (proc init) limit)))) | |
(define (accumulate op init seq) | |
(if (null? seq) | |
init | |
(+ (car seq) (accumulate op init (cdr seq))))) | |
(accumulate + 0 (enum-nums (lambda (n) (+ 1 n)) 1 100)) |
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
#include <stdio.h> | |
#define N 7 | |
int min(int* nums, int len); | |
int max(int* nums, int len); | |
int first_appear(int* nums, int len, int target); | |
int main(int argc, char* argv[]) | |
{ | |
int i, len, target; |
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
# -*- encoding:utf-8 -*- | |
# | |
# Usage | |
# | |
# tokyo = Weather.new :tokyo | |
# okinawa = Weather.new("沖縄") | |
# fuchu = Weather.new("東京都府中市") | |
# | |
# puts fuchu.get_weather(:today).to_s | |
# puts fuchu.get_weather(0).to_s |
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
# Ruby install 覚え書き | |
# gcc make gcc-c++ zlib-devel httpd-devel openssl-devel curl-devel libreadline-dev readline-dev あたりがはいっているか確認 | |
# install rbenv | |
$ cd | |
$ git clone git://github.com/sstephenson/rbenv.git .rbenv | |
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc | |
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc | |
$ source ~/.bashrc |
OlderNewer