Python の話なんですが
Pythonについて(アンチ専用)
562 デフォルトの名無しさん [] 2009/11/03(火) 20:47:51 ID: Be:
インデント記法は慣れれば気にならないし、
xx.lenghがなくてlen(xx)に統一されてるのも
個人的には嫌いだけど一理あるとは認めざる得ない。
でもスライスのx[n:m]の範囲指定は気持ち悪い。
なんか合理的な理由でもあるの?
563 デフォルトの名無しさん [sage] 2009/11/03(火) 20:52:51 ID: Be:
他にどんな方法があるの?
564 デフォルトの名無しさん [sage] 2009/11/03(火) 21:37:23 ID: Be:
>>562
日本語の勉強してから出直せ
565 デフォルトの名無しさん [sage] 2009/11/03(火) 21:38:46 ID: Be:
>>563
[n:m] が n~(m-1) が気持ち悪いっていう意味だろうと E.S.P.
漏れは合理的だと思うけどね
566 デフォルトの名無しさん [] 2009/11/03(火) 21:47:04 ID: Be:
>>565
ああそういう意味か
漏れも>>562が何言ってるのか判らんかった
例えばx文字目からy文字(文字数)取り出すとき
s[x:x+y-1]
とするよりも
s[x:x+y]
の方が計算が少なくて済むし
逆にpythonの中の人も
s[x:y]
が与えられたときに長さが
y-x+1
じゃなくて
y-x
となってここも計算が少なくて済む
小学生でも判るレベルの話
567 デフォルトの名無しさん [sage] 2009/11/03(火) 21:58:48 ID: Be:
x文字目からy文字目まで取り出すとき
s[x:y+1]と計算が多くて済むから合理的
568 デフォルトの名無しさん [] 2009/11/03(火) 22:31:58 ID: Be:
x文字目から最後の文字からn文字前まで取り出すとき
s[x:-n]と計算が少なくて済むから合理的
>>> 'abcde'[2:]
'cde'
>>> 'abcde'[2:-1]
'cd'
>>> 'abcde'[2:-2]
'c'
569 デフォルトの名無しさん [] 2009/11/03(火) 22:33:52 ID: Be:
s = 'abcde'
s[2:len(s)]
s[2:len(s)-1]
s[2:len(s)-2]
-1 が最後の要素の添え字なのはいいのですが、範囲で指定する場合には
「その次の値」を与えるので
>>> l = range(1,11)
>>> l
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> l[:]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> l[:] = range(11,21)
>>> l
[11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
>>> l[0:] = range(11,21)
>>> l
[11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
>>> l[0:0] = range(11,21)
>>> l
[11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
>>> l = range(0,10)
>>> l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> l[0] = 100
>>> l
[100, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> l[-1] = 99
>>> l
[100, 1, 2, 3, 4, 5, 6, 7, 8, 99]
>>> l[1:4] = [21, 22, 23]
>>> l
[100, 21, 22, 23, 4, 5, 6, 7, 8, 99]
>>> l[0:] = range(21,31)
>>> l
[21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
>>> l[:] = range(31,41)
>>> l
[31, 32, 33, 34, 35, 36, 37, 38, 39, 40]
>>> l[0:-1] = range(31,41)
>>> l
[31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 40]
>>> l[0:0] = range(41,51)
>>> l
[41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 40]
>>>
ちょっと悲しいことに。確かに [:] (もしくは [0:])と書けばリスト全体が指定できますが、
そうすると、リスト全体のときとそうでないときとで書き分けなければならないですよね。
なんかちょっと悔しいw
Inf のようなものがあって、[0:Inf]とかできればいいのだろうか。
まあ今更なネタですね。はい。
いろいろ面白そうなのは日々見つかるんですが。
What a Monad is not - HaskellWiki
What a Monad is not
Contents
* 1 Warning
* 2 Monads are not a good choice as topic for your first Haskell blog entry
* 3 Monads are not a language feature
* 4 Haskell doesn't need Monads
* 5 Monads are not impure
* 6 Monads are not about state
* 7 Monads are not about strictness
* 8 Monads are not values
* 9 Monads are not a replacement for applicative functors
* 10 Monads are not about ordering
(以下略)
State of Ruby VMs: Ruby Renaissance - igvita.com
State of Ruby VMs: Ruby Renaissance
Ruby is commonly associated with the frameworks (Rails, RSpec, and many others) that
it enabled, but it is much more then that. The same ideology and design principles
that popularized the language at the start are also the reason why it is being
currently ported to a variety of alternative platforms: JVM, Objective-C, Smalltalk VM
and Microsoft's DLR. Technical details aside, few will disagree that Matz's focus on
“how we feel while programming” and the objective of “making the programmer happy”
has resonated with the larger community.
Ruby は (Rails, RSpec, その他もろもろ) フレームワークと結び付けられることが一般的です
が、it is much more then that.開発を始めたときにに言語を popularized した同じイデオロ
ギーとデザインの原則は現時点でJVM, Objective-C, Smalltalk VM and Microsoft's DLR
といったvariety of alternative platforms に移植されている理由でもあります:
技術的な詳細はさておいて、Matz が “how we feel while programming” にフォーカスして
“making the programmer happy”(“プログラマーを幸福にする”)という目的が大きなコミュ
ニティと resonate (共鳴) したということに反対する人はそれほどいないでしょう。
In a short span of just a couple of years, the Ruby VM space has evolved to more than
just a handful of choices: MRI, JRuby, IronRuby, MacRuby, Rubinius, MagLev, REE and
BlueRuby. In fact, keeping up with all of the most recent developments within each VM
is now easily a full-time job. For that reason, and with RubyConf ‘09 in full swing,
let's take a quick survey of the space and where it's taking us.
ほんの二、三年という短いスパンではMRI, JRuby, IronRuby, MacRuby, Rubinius, MagLev, REE
and BlueRuby のように、Ruby VM の space は just a handful of choices という範囲を越え
て広がっています:
In fact, keeping up with all of the most recent developments within each VM
is now easily a full-time job.
For that reason, and with RubyConf ‘09 in full swing,
let's take a quick survey of the space and where it's taking us.
2010: Year of Ruby Renaissance (Ruby の Renaissance の年)
(以下略)