LoginSignup
0
0

More than 5 years have passed since last update.

C# と pythonのlambda式

Posted at

最近pythonとunityを行き来するので
忘備録メモ

Python

list = [1, 2, 3, 4, 5]

# lambda {引数}: {処理内容&return}
map(lambda x: x *2,  list)
# [2, 4, 6, 8, 10]

C#

linq使ってますが

using System.Linq;

int[] list = new int[] {1, 2, 3, 4, 5}

//{引数} => {処理内容&return}
list.Select(x => x * 2); 
// { 2, 4, 6, 8, 10 }

Elixir

オマケ

list = [1, 2, 3, 4, 5]

# fn ( {引数} ) ->  {処理内容&return} end
Enum.map(list, fn(x) -> x * 2 end)

# [2, 4, 6, 8, 10]
0
0
1

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
0
0