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
class StopWatch { | |
public static void main(String[] args) | |
throws InterruptedException // thrown by Thread.sleep() | |
{ | |
for (int h = 0; h < 24; h++) { | |
for (int m = 0; m < 60; m++) { | |
for (int s = 0; s < 60; s++) { | |
System.out.printf("%2d:%02d:%02d\n", h, m, s); | |
Thread.sleep(1000); // 1000 ms = 1.0 sec | |
} |
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
-- FizzBuzz in Haskell | |
fizzBuzz n | n `mod` 15 == 0 = "FizzBuzz" | |
| n `mod` 3 == 0 = "Fizz" | |
| n `mod` 5 == 0 = "Buzz" | |
| otherwise = show n | |
main = do | |
putStr $ show $ map fizzBuzz [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
(cond-expand | |
(guile (use-modules (srfi srfi-42))) | |
(gauche (use srfi-42)) | |
(racket (require srfi/42)) | |
(plt (require (lib "42.ss" "srfi"))) | |
(srfi-42 #t)) | |
(list-ec (: k 10) k) ; 0 から始まり,10 の直前まで | |
(list-ec (: k 10) (* k k)) ; 0 から始まり,10 の直前まで k の 2乗 | |
(list-ec (: k 1 10) k) ; 1 から始まり,10 の直前まで |
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
class Crystal { | |
float x, y, phi; | |
Crystal(float x0, float y0, float phi0) { | |
x = x0; | |
y = y0; | |
phi = phi0; | |
} | |
void fall() { |
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
class Crystal { | |
float x, y, phi; | |
Crystal(float x0, float y0, float phi0) { | |
x = x0; | |
y = y0; | |
phi = phi0; | |
} | |
void fall() { |
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
import java.security.MessageDigest | |
def hexBytes(bs: Array[Byte]):String = | |
bs.map("%02X".format(_)).mkString(" ") | |
val md2 = MessageDigest.getInstance("MD2") | |
val md5 = MessageDigest.getInstance("MD5") | |
val sha1 = MessageDigest.getInstance("SHA-1") | |
val sha256 = MessageDigest.getInstance("SHA-256") | |
val sha384 = MessageDigest.getInstance("SHA-384") |
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
void setup() { | |
size(500, 500); | |
fill(255, 255, 0); // YELLOW | |
pentagon(250, 250, 100); | |
} | |
/** drawing a pantagon inscribed a circle as radius r ans its center is placed at (x, y). | |
*/ | |
void pentagon(float x, float y, float r) { | |
pushMatrix(); |
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
void setup() { | |
size(500, 500); | |
noStroke(); | |
fill(255, 255, 0); | |
for (int i = 0; i < 10; i++) { | |
star(random(width), random(height), 30); | |
} | |
} | |
void star(float x, float y, float r) { |
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
void setup() { | |
size(500, 500); | |
for (int i = 0; i < 20; i++) { | |
hexagon(random(width), random(height), 20); | |
} | |
} | |
/** drawing a hexagon inscribed a circle as radius r and its center is placed at (x, y). | |
*/ | |
void hexagon(float x, float y, float r) { |
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
void setup() { | |
size(500, 500); | |
crystal(250, 250, 100); | |
} | |
void hexagon(float x, float y, float r) { | |
pushMatrix(); | |
translate(x, y); | |
beginShape(); | |
for (int i = 0; i < 6; i++) { |