- Subject: Re: list to array conversion?
- From: "G. Milde" <g.milde@xxxxxx>
- Date: Thu, 13 Apr 2006 09:45:42 +0200
On 12.04.06, John E. Davis wrote:
> Marko Mahnic <marko.mahnic@xxxxxxxx> wrote:
> >Maybe there could be a where() version for lists:
> >
> > where([DataType_Type type,] condition)
> >
> >? It would only perform a test on a certain type of elements.
>
> I eventually plan to extend the comparison operators to lists. Then
> you would be able to do something like:
>
> i = where (list > 3);
> For this to be useful, list[i] should return a "sublist".
Slicing via array args as e.g. liste[[1:3]] would indeed be a very nice
feature, not only for where() results.
(This slicing notation is even more powerfull than the one used in
Python, as it allows "arbitrary spare" sublists|subarrays as with
liste[[1,4,5,22]].)
> Of course this will not work if a list consists of datatypes where the
> comparison makes no sense. For this reason, my inclination would be to
> throw an exception if a comparison were made on a list containing such
> elements.
However, one could consider extending the `case' like comparision, say a
function wherecase(container, comparator), where
wherecase({0,1,2,3,"vier",5,2}, 2)
would return [2,6] instead of throwing an exception. It should also work
for Any_Type arrays.
And how about a list_map() alongside array_map() or maybe a map()
replacing both?
Guenter
--
Milde ife.et.tu-dresden.de
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2006 date index]
[2006 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]