1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2006-2008 Jean Privat <jean@pryen.org>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
19 fun val1
: Int is abstract
20 fun val2
: Int do return val1
26 redef fun val1
: Int do return a
28 redef fun to_s
do return "Aa{a}"
34 redef fun val1
: Int do return b
/2
35 redef fun val2
: Int do return b
40 redef fun to_s
do return "Bb{b}"
47 redef fun val1
: Int do return c
48 redef fun val2
: Int do return d
50 redef fun to_s
do return "Cc{c}d{d}"
56 redef fun val1
: Int do return a
57 redef fun val2
: Int do return b
61 redef fun to_s
do return "Da{a}b{b}"
66 redef fun val1
: Int do return 5
68 redef fun to_s
do return "Eb{b}"
73 redef type COMPARED: Elt
74 redef fun compare
(a
, b
)
77 return a
.val1
<=> b
.val1
79 return a
.val2
<=> b
.val2
88 var is_val1
: Bool = false
101 return new C
(10.rand
, 10.rand
)
103 return new D
(10.rand
, 10.rand
)
105 return new E
(10.rand
)
112 if not args
.is_empty
then
116 var array
= new Array[Elt].with_capacity
(n
)
118 array
.push
(generator
)
121 print array
.join
(", ")
123 var comparator
= new EltComparator
125 comparator
.sort
(array
)
129 print array
.join
(", ")