Untitled

Run Settings
LanguageNim
Language Version
Run Command
type Node = ref object of RootObj prev, next: Node data: string List = ref object of RootObj starting, ending: Node count: int proc addItem( list: List, val: string ): int = if list.count == 0: list.starting = Node() list.starting.data = val list.ending = list.starting else: list.ending.next = Node() list.ending.next.prev = list.ending list.ending = list.ending.next list.ending.data = val list.count += 1 result = list.count proc delItem( list: List, val: string ): int = if list.count == 0: return -1 var itr = list.starting while itr != nil: if itr.data == val: break itr = itr.next if itr == nil: return -1 if itr.prev != nil: itr.prev.next = itr.next if itr.next != nil: itr.next.prev = itr.prev itr = nil list.count -= 1 result = list.count iterator items( list: List ): string = var itr = list.starting while itr != nil: yield itr.data itr = itr.next if isMainModule: var list: List = List( starting: nil, ending: nil, count: 0 ) echo addItem( list, "hello" ) echo addItem( list, "world" ) for item in list: echo item echo delItem( list, "world" ) for item in list: echo item
Editor Settings
Theme
Key bindings
Full width
Lines