Head and Rest via Generics

  • Thread starter Thread starter Seasanctuary
  • Start date Start date
S

Seasanctuary

I want to make sure that someone mentions that Generics will allow the
..NET framework Array and other similarly interfaced collections to
implement .Head() and .List() methods to return the first and the rest
of the items in an existing array respectively...like LISP et al..

Adding CONS semantics to + operators would also be handy.

I'm using a lot of recursive functions right now and have to make
silly auxillary methods to handle all of this specifically for the
data types. This is awful. I can't wait to write lines like:

return arguments.Head + separatorToken + SameFunction(arguments.Rest);
 
Seasanctuary said:
I want to make sure that someone mentions that Generics will allow the
.NET framework Array and other similarly interfaced collections to
implement .Head() and .List() methods to return the first and the rest
of the items in an existing array respectively...like LISP et al..

Adding CONS semantics to + operators would also be handy.

I'm using a lot of recursive functions right now and have to make
silly auxillary methods to handle all of this specifically for the
data types. This is awful. I can't wait to write lines like:

return arguments.Head + separatorToken + SameFunction(arguments.Rest);

While Head and Rest are useful for functional languages, I can't see
them being particularly useful in C#. Why not just specify an index
instead?

return arguments[index] + separatorToken + SameFunction (arguments,
index+1);
 
Back
Top