3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Elmの無名関数は"\..."と書かずに"λ..."でもOK

Posted at

unicodeのλで無名関数をかける

Elmの無名関数はカッコ(..)で括ってても必ずバックスラッシュ\...で始めないといけません
これは時間空くと忘れそうだなと思ってました

実はバックスラッシュを使わず、ラムダλ..(unicodeの)を使ってもOK

  • documentには書いてません
  • さらに、右方向のアロー演算子->とUnicodeつかえるらしい

ってことで、次のように書いても問題なく動く

import Html exposing (..)
main =
  List.map (λn  n^2) [1..10]
    |> List.foldr (+) 0
    |> toString
    |> text

- Try Elmにこのコードコピペして確認できる

とはいえ、実際には自分が使うエディタの入力では入力大変なので使わないだろうけど

ここで紹介されてた

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?