In F# (|>) is important because of the left-to-right typechecking. For example: List.map (fun x -> x.Value) xs generally won't typecheck, because even if the type of xs is known, the type of the argument x to the lambda isn't known at the time the typechecker sees it, so it doesn't know how to resolve x.Value.
UNIXはシンプルである。必要なのはそのシンプルさを理解する素質だけである -- Dennis Ritchie
現役コーダーに質問。 (スコア:0)
1 |> print
print(1)
「|>」なんて今まで書いたり見たりしたコードにないんですが、使うんですか?
使うなら何言語ですか?
class::expressionのように::はありますが。
あとprint(1)ではなくてprint('1');では?
Re:現役コーダーに質問。 (スコア:0)
F#に始まり、Haskellなどでも採用されていますね。
記号は | だけになりますが方向性が似ているパイプ(ライン)は今も多数のOSのシェルスクリプト上で現役だと思いますし。
1 と '1' についてはそれを質問するほど基礎的な素養がない人に説明するには長くなりますし、
その目的でこの場所を使うことは不適切だと思いますので、ご自分でECMAScriptの入門書なりを買って勉強してください。
Re: (スコア:0)
ふ〜ん ocamlじゃないんだ
Re: (スコア:0)
In F# (|>) is important because of the left-to-right typechecking. For example:
List.map (fun x -> x.Value) xs
generally won't typecheck, because even if the type of xs is known, the type of the argument x to the lambda isn't known at the time the typechecker sees it, so it doesn't know how to resolve x.Value.