POV-Ray : Newsgroups : povray.off-topic : Reflections on employment : Re: Reflections on employment Server Time
28 Jul 2024 20:34:40 EDT (-0400)
  Re: Reflections on employment  
From: Orchid Win7 v1
Date: 2 Dec 2012 10:54:49
Message: <50bb79c9$1@news.povray.org>
On 02/12/2012 03:06 PM, Warp wrote:
> Orchid Win7 v1<voi### [at] devnull>  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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.