Slide 11
Slide 11 text
使用例
using System.Linq;
var src = new int[] { 3, 8, 2, 1, 5, 7, 4, 6 };
var e = src
.Where(n => n % 2 == 0)
.OrderBy(n => n)
.Select(n => $"{n}");
var arr = e.ToArray();
Console.WriteLine(string.Join(",", arr));
// "2,4,6,8"
src := []int{ 3, 8, 2, 1, 5, 7, 4, 6 }
e1 := linq.FromSlice(src)
e2 := linq.Where(e1,
func(n int)(bool, error){ return n%2==0, nil })
e3 := linq.OrderBy(e2,
func(n int)(int, error) { return n, nil })
e4 := linq.Select[int](e3,
func(n int) (string, error) {
return strconv.Itoa(n), nil })
arr, _ := linq.ToSlice(e4)
fmt.Println(strings.Join(arr, ",")) // "2,4,6,8"