# Basic list operations @use Abstract. Abstract : Lists { # Returns list of size s1, where each index contains a list # consisting of (s2 * s3) empty lists. + to list-of-blanks size1 s1 (int) size2 s2 (int) size3 s3 (int): blanks (list). i (int). j (int). k (int). blanks = {}. for i = 0, i < s1, i++ : { push {} onto blanks. for j = 0, j < s2, j++ : { for k = 0, k < s3, k++ : push {} onto (blanks{i}). } } return blanks. + to ascending-sort the-list l (list): sort l with minus. # For sorting + to minus lhs a (double) rhs b (double): return (a - b). # x: int value to search for # xs: list of int values to search in + to contains element x (int) in-list xs (list): i (int). for i=0, i<|xs|, i++ : { if (x == xs{i}) : return 1. } return 0. + to contains-string element x (string) in-list xs (list): i (int). for i=0, i<|xs|, i++ : { if (x == xs{i}) : return 1. } return 0. + to list-or lhs xs (list) rhs ys (list): i (int). result (list). result = {}. for i = 0, i < |xs|, i++ : { if (xs{i} || ys{i}) : { push 1 onto result. } else { push 0 onto result. } } return result. + to second-element-ascending-sort the-list l (list): sort l with compare-by-second. # val1: list containing at least two indicies # val2: list containing at least two indicies # - used for sorting by second values + to compare-by-second value val1 (list) to val2 (list): return (val1{1} - val2{1}). # Creates new list that is the union of the two inputs + to union lhs xs (list) rhs ys (list): i (int). result (list). result = {}. for i = 0, i < |xs|, i++ : { push (xs{i}) onto result. } # No duplicates in union for i = 0, i < |ys|, i++ : { if !(self contains-string element (ys{i}) in-list result) : { push (ys{i}) onto result. } } return result. + to set-diff lhs xs (list) rhs ys (list): i (int). result (list). result = {}. for i = 0, i < |xs|, i++ : { if !(self contains-string element (xs{i}) in-list ys) : { push (xs{i}) onto result. } } return result. + to push-all from add (list) on-to target (list): i (int). for i = 0, i < |add|, i++ : { push (add{i}) onto target. } }