# 星之一角

What have you found for these years?

## 2009-04-25

### python vs ruby...

`godfat ~> pythonPython 3.0 (r30:67503, Mar 14 2009, 22:52:13) [GCC 4.0.1 (Apple Inc. build 5484)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> a = b = []>>> a += [1]>>> a[1]>>> b[1]`

`>>> a = b = []>>> a = a + [1]>>> a[1]>>> b[]`

ruby 裡比較符合我的直覺：
`godfat ~> irb1.9irb(main):001:0> a = b = []=> []irb(main):002:0> a += [1]=> [1]irb(main):003:0> a=> [1]irb(main):004:0> b=> []irb(main):005:0> a = b = []=> []irb(main):006:0> a = a + [1]=> [1]irb(main):007:0> a=> [1]irb(main):008:0> b=> []irb(main):009:0>`

`t = time.time()gt = time.gmtime(t)hour = int(t) - int(time.strftime("%S", gt)) - int(time.strftime("%M", gt)) * 60`

vs
`t = Time.nowhour = t.to_i - t.sec - t.min * 60`

#### 12 retries:

Python 真的是比 Ruby 囉嗦一點

Unknown said...

Q:下面G1與G2是兩個文法，請說明：
G1：N={∑,A},T={a,b},P={∑->A,A->bAa,A->ba}
G2：N={∑,A,B},T={a,b,c},P={∑->Bbc,Ab->bA,Ac->bcc,Bb->aBbA,B->a}
(一)何者是上下文無關文法？
(二)G1與G2的文法將分別產生什麼樣的字串？

Lin Jen-Shin (godfat) said...

> 老林 提到...

*

> 媺珊 提到...

http://flolac.iis.sinica.edu.tw/lambdawan/

Unknown said...

Lin Jen-Shin (godfat) said...

Anonymous said...
This comment has been removed by a blog administrator.
pigfoot said...

a = b = [] 代表完全是一樣的東西, a 作了甚麼變動, b 也會跟著變, 因為 list 是 reference.

a = a + [1] 代表是把 a+[1]的結果, 給一個新的變數, 但是這個變數剛好是 a, 所以這個 a 就和之前的 b 不一樣了.

Lin Jen-Shin (godfat) said...

*

Mr. BigCat said...

Lin Jen-Shin (godfat) said...

c++ 也是可以定義 +=,

Anonymous said...
This comment has been removed by a blog administrator.
Lin Jen-Shin (godfat) said...