LMList: LMList

Description Usage Arguments Examples

View source: R/LML.R

Description

Limited Memory List. Adds new element to top of list, removing bottom elements if new length is greater than M.

Usage

1
LMList(new_el, old_list = list(), M = 1)

Arguments

new_el

element to add to top of list

old_list

list to append new_el to

M

maximum size of list (will truncate by removing bottom if length is greater than M). If M==0, the list will have 'unlimited' memory.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# create a new LM List, with 2 element memory:
lm = LMList("horse", M=2)
print(lm)

# append new item
lm = LMList("buggy", lm, M=2)
print(lm)

# append a third item (will forget the oldest)
lm = LMList("driver", lm, M=2)
print(lm)

mrparker909/LimitedMemoryList documentation built on Nov. 4, 2019, 7:35 p.m.