|
![](/i/fill.gif) |
On 02/12/2012 03:06 PM, Warp wrote:
> Orchid Win7 v1<voi### [at] dev null> wrote:
>> Here's a challenge - write me a C# function (or even just some
>> psuedocode) which will take a string containing space-delimited positive
>> integers, and return them in ascending order.
>
> If it were C++, I could write a few lines of code that does that
Haskell:
foobar :: String -> [Int]
foobar = sort . map read . words
C#:
public List<Int> foobar(String s)
{
string[] words = s.Split(' ');
List<Int> list = new List<Int>();
foreach (String word in words) {list.add(int.Parse(word));}
list.Sort();
return list;
}
Not exactly taxing, eh?
Post a reply to this message
|
![](/i/fill.gif) |