Another quizz to be added into main list

1 view
Skip to first unread message

Aleksandr Motsjonov

unread,
Mar 12, 2010, 3:29:54 AM3/12/10
to codin...@googlegroups.com
Write a method, whose arguments are array and number (n), which returns same array, but where first n elements are in the end.
For ex:
[1,2,3,4,5,6,7] n = 3
must returns:
[4,5,6,7,1,2,3]

And there is one rule: you can use only one array (given as arguments)

Alex.

David Pollak

unread,
Mar 12, 2010, 9:39:35 AM3/12/10
to codin...@googlegroups.com
Can I suggest using a List or a Seq rather than an array.  The overhead in 2.8 related to Arrays distract from the intent of the Kata.

--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Aleksandr Motsjonov

unread,
Mar 12, 2010, 9:42:51 AM3/12/10
to codin...@googlegroups.com
I don't know. The idea was about something mutable with constant width. And you need to swap items in it making as less as possible number of it (swaps)
Maybe it's not best idea for Kata =)

David Pollak

unread,
Mar 12, 2010, 1:02:46 PM3/12/10
to codin...@googlegroups.com
On Fri, Mar 12, 2010 at 6:42 AM, Aleksandr Motsjonov <sos...@gmail.com> wrote:
I don't know. The idea was about something mutable with constant width. And you need to swap items in it making as less as possible number of it (swaps)
Maybe it's not best idea for Kata =)

I think it's interesting, although I guess I like the idea of focusing on immutability for a Kata to get folks practicing their immutability skills.
 

On Fri, Mar 12, 2010 at 4:39 PM, David Pollak <feeder.of...@gmail.com> wrote:


On Fri, Mar 12, 2010 at 12:29 AM, Aleksandr Motsjonov <sos...@gmail.com> wrote:
Write a method, whose arguments are array and number (n), which returns same array, but where first n elements are in the end.
For ex:
[1,2,3,4,5,6,7] n = 3
must returns:
[4,5,6,7,1,2,3]

And there is one rule: you can use only one array (given as arguments)

Alex.

Can I suggest using a List or a Seq rather than an array.  The overhead in 2.8 related to Arrays distract from the intent of the Kata.

--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Reply all
Reply to author
Forward
0 new messages