Lichen

Change of lib/__builtins__/list.py

516:360560918d91
lib/__builtins__/list.py
     1.1 --- a/lib/__builtins__/list.py	Sat Jan 28 23:32:15 2017 +0100
     1.2 +++ b/lib/__builtins__/list.py	Sun Jan 29 00:18:52 2017 +0100
     1.3 @@ -3,7 +3,7 @@
     1.4  """
     1.5  List objects.
     1.6  
     1.7 -Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
     1.8 +Copyright (C) 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
     1.9  
    1.10  This program is free software; you can redistribute it and/or modify it under
    1.11  the terms of the GNU General Public License as published by the Free Software
    1.12 @@ -22,7 +22,7 @@
    1.13  from __builtins__.iterator import itemiterator
    1.14  from __builtins__.sequence import sequence
    1.15  from native import list_append, list_concat, list_element, list_init, \
    1.16 -                   list_len, list_nonempty, list_setelement
    1.17 +                   list_len, list_nonempty, list_setelement, list_setsize
    1.18  
    1.19  class list(sequence):
    1.20  
    1.21 @@ -59,8 +59,19 @@
    1.22          for i in iterable:
    1.23              self.append(i)
    1.24  
    1.25 -    def pop(self): pass
    1.26 +    def pop(self):
    1.27 +
    1.28 +        "Remove the last item from the list, returning the item."
    1.29 +
    1.30 +        i = self[-1]
    1.31 +
    1.32 +        # NOTE: Should truncate the allocated list after several pops.
    1.33 +
    1.34 +        list_setsize(self.__data__, self.__len__() - 1)
    1.35 +        return i
    1.36 +
    1.37      def reverse(self): pass
    1.38 +
    1.39      def sort(self, cmp=None, key=None, reverse=0): pass
    1.40  
    1.41      def __len__(self):
    1.42 @@ -69,7 +80,13 @@
    1.43  
    1.44          return list_len(self.__data__)
    1.45  
    1.46 -    def __add__(self, other): pass
    1.47 +    def __add__(self, other):
    1.48 +
    1.49 +        "Add this list to 'other', producing a new list."
    1.50 +
    1.51 +        l = list(self)
    1.52 +        l.extend(other)
    1.53 +        return l
    1.54  
    1.55      def __iadd__(self, other):
    1.56