The samples for restriction and projection in interactive shell.
Ruby 1.9's Enumerable on Mac OS X
$ irb1.9
irb(main):001:0> one_to_ten = 1..10
=> 1..10
irb(main):002:0> one_to_ten.find_all {|i| i % 2 == 1 }.collect {|i| i**2}
=> [1, 9, 25, 49, 81]
Mono(C#)'s Linq to Object on Mac OS X
$ csharp
Mono C# Shell, type "help;" for help
Enter statements below.
csharp> using System.Linq;
csharp> int[] oneToTen = new int[]{1,2,3,4,5,6,7,8,9,10};
csharp> oneToTen.Where(i => i % 2 == 1).Select(i => Math.Pow(i, 2));
{ 1, 9, 25, 49, 81 }
No comments:
Post a Comment