Newbie question :Sort a liste of tuple
Torsten Anders
t.anders at qub.ac.uk
Sat Oct 30 17:05:13 CEST 2004
On Sat, 2004-10-30 at 01:49, Boriss Mejias wrote:
> Raphael Collet wrote:
> > Hi Vincent,
> >
> >
> >>I have a liste of tuple like that : [ A1#B1 A2#B2 A3#B3 ....]
> >>I would like to sort it using A for ordering key
> >>
> >>I have try to use this :
> >>
> >>{List.sort List fun {$ A1#B1 A2#B2} A1 < A2 end Test}
> >
> > ^^^^
> > It's definitely not a good idea to call a list "List", because you don't
> > have access to the List module anymore. What happened is that you have
> > redeclared List to be a list. Therefore List.sort tries to access the
> > field "sort" from a list...
> >
> > A lot of experienced Oz programmers use less confusing identifiers for
> > lists, such as "L" and "Xs" ;-)
>
> Why is it List a confusing identifier for a List?
> Just because of the existing module List?
> Or did I missed the <ironic mode> tag in the comment?
Many things in Oz are so called first-class values: a function, a class
or a functor/module are values just as numbers or strings are. You can
bind such values to a variable to reference it.
The list module is already bound to the variable List when you start Oz.
If you introduce another variable with the same name (e.g. as an
argument in a function), the variable bound to the list module becomes
unaccessible in the scope of the new variable with the same name.
Best,
Torsten
--
Torsten Anders
Sonic Arts Research Centre
Queen's University Belfast
Tel: +44 28 9097 4761 (office)
+44 28 9066 7439 (private)
www.torsten-anders.de
More information about the mozart-users
mailing list