예제 #1
0
def main(intlist, value, index):
    intliststring = str(intlist)[1:len(str(intlist)) - 1]
    intlist = intliststring.split(", ")
    newlist = []
    for each in intlist:
        newlist.append(int(each))
    newlist.insert(index, value)
    return i.IntList(newlist)
예제 #2
0
def main(intlist, index, value):
    listarray = insertinmiddle(intlist, index)
    tmp = listarray[1].cons(value)
    for each in reversed(listarray[0]):
        tmp = tmp.cons(ilist.IntList(each))
    return tmp
예제 #3
0
import intlist as ilist

def insertinmiddle(intlist, index):
    count = 0
    firsthalf = []
    while count < index:
        firsthalf.append(intlist.first())
        intlist = intlist.rest()
        count += 1
    return [firsthalf, intlist]

def main(intlist, index, value):
    listarray = insertinmiddle(intlist, index)
    tmp = listarray[1].cons(value)
    for each in reversed(listarray[0]):
        tmp = tmp.cons(ilist.IntList(each))
    return tmp

print(str(main(ilist.IntList([1,2,4,5]), 2, 3)))
예제 #4
0
import intlist

n1 = intlist.IntList([2, 3, 4, 5, 6, 7])

# fulllist = [n1.first].append(n1.rest)
def ithinkthishastoberecursive(n1):
    if(n1.nil == False):
        print(n1.first())
        return ithinkthishastoberecursive(n1.rest())
    else:
        return

ithinkthishastoberecursive(n1)
예제 #5
0
import intlist as i


def main(intlist, value, index):
    intliststring = str(intlist)[1:len(str(intlist)) - 1]
    intlist = intliststring.split(", ")
    newlist = []
    for each in intlist:
        newlist.append(int(each))
    newlist.insert(index, value)
    return i.IntList(newlist)


print(main(i.IntList([1, 2, 4, 5]), 2, 3))