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
print "Hello, World!\n" | |
# on python 3.*, print ("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
#!/bin/bash | |
for i in `seq 1 400`; | |
do | |
printf "%3d\t" "$i" | |
aplay /usr/share/skype/sounds/SkypeLogin.wav | |
done |
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 Hello(object): | |
def __init__(self, friend): | |
self.friend = friend | |
def sayhello(self): | |
print "Hello, %s!"%(self.friend) | |
# helloworld = Hello('World') | |
# helloworld.sayhello() |
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
for element in a: | |
do_something_with(element) |
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
# 1 | |
for element in a | |
do_something_with(element) | |
end | |
# 2 | |
a.each do |element| | |
do_something_with(element) | |
end |
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
#!/usr/bin/python | |
# encoding:utf-8 | |
import random | |
class Neuron(object): | |
# 神経細胞体 class. | |
# i) synapse からの入力を受けることができ, | |
# ii) ある間にうけた入力の総和が threshold を超えれば | |
# iii) 発火し,本人から出ていく synapse に伝達される. |
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
#!/usr/bin/python | |
# encoding:utf-8 | |
import random | |
THRESHOLD = 1 # threshold for neuron's firing. | |
SYNAPSE_LIMIT = 4 # how strong synapses are allowed to be. | |
LTPRATIO = 1.1 # LTP : strength = strength*LTPRATIO | |
FORGETRATIO = 0.95 # A little forgetfullness | |
SUPPRESSION_RATIO = 0.5 # the frequency of suppressive synapses | |
SUP_WEAKNESS = 0.7 # when initialising, |
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
b :: Integral a => a -> a -> a --なんか数が2個入ったら中で色々やって数が1個出て来るような b っていうものがあるとするわね | |
b m n | |
| m == 0 = f n -- b の頭に 0, 尻になんか入ったらこうなる | |
| n == 0 = b (m-1) 1 -- b の頭に 0 より大きい数,尻に 0 が入った場合こうなる | |
| otherwise = b m $ b (m+1) n -- b の頭にも尻にも 0 でない数が入った場合こうなる | |
f :: Integral a => a -> a -- f っていうのは数が1個入ったら中で色々やって数が1個出てくるようなもの | |
f n = n + 1 -- この f は入った数に 1 を加えて出すというルールってことにしましょうか |
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
#!/usr/bin/python | |
''' | |
heapsort | |
from : https://en.wikipedia.org/wiki/Heapsort#Pseudocode | |
''' | |
def heapsort(a): | |
''' input : an unordered array a''' | |
count = len(a) | |
# first place a in max-heap order |
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
#!/usr/bin/python | |
# coding:utf-8 | |
# from : http://urasunday.com/u-2_09/comic/002_001.html | |
class B(object): | |
def __init__(self, m, n, f=lambda n: n+1): | |
self.m = m | |
self.n = n | |
self.f = f |
OlderNewer