R
Ralf Müller
Hi,
i had an idea of a cyclic list. It came to my mind months ago and the
implementation in ruby was so simple:
class RoundList < Array
def initialize(size)
@@size = size
end
def add(k,v)
self[k%@@size] = v
end
def get(i)
self[i%@@size]
end
end
# r = RoundList.new(3)
# => []
# r.add(1,"eins")
# => "eins"
# r
# => [nil, "eins"]
# r.add(0,r)
# => [[...], "eins"]
# r.add(2,r)
# => [[...], "eins", [...]]
# r.get(0)
# => [[...], "eins", [...]]
# r.get(0).get(0)
# => [[...], "eins", [...]]
# r.get(0).get(0).get(2)
# => [[...], "eins", [...]]
when I saw this, i had a weird feeling of complexity. Mixing different
RoundLists, fasten them with knots, creating some kind loop-structure and all
this seems to be endless because r.get(0).get(0) == r.get(0).get(0).get(0) ...
I couldn't and cannot imagine, how this construction can be usefull.
If anyone of you CAN imagine, please let me know.
best regards
ralf
--
i had an idea of a cyclic list. It came to my mind months ago and the
implementation in ruby was so simple:
class RoundList < Array
def initialize(size)
@@size = size
end
def add(k,v)
self[k%@@size] = v
end
def get(i)
self[i%@@size]
end
end
# r = RoundList.new(3)
# => []
# r.add(1,"eins")
# => "eins"
# r
# => [nil, "eins"]
# r.add(0,r)
# => [[...], "eins"]
# r.add(2,r)
# => [[...], "eins", [...]]
# r.get(0)
# => [[...], "eins", [...]]
# r.get(0).get(0)
# => [[...], "eins", [...]]
# r.get(0).get(0).get(2)
# => [[...], "eins", [...]]
when I saw this, i had a weird feeling of complexity. Mixing different
RoundLists, fasten them with knots, creating some kind loop-structure and all
this seems to be endless because r.get(0).get(0) == r.get(0).get(0).get(0) ...
I couldn't and cannot imagine, how this construction can be usefull.
If anyone of you CAN imagine, please let me know.
best regards
ralf
--