Code/Python

Lists

maetel 2007. 8. 1. 13:17
ref. 이강성 <열혈강의 파이썬> 5장 리스트

List 리스트: 순서를 가지는 객체들의 집합.

1) 시퀀스 자료형이면서 변경 가능(mutable) 형이다.
    : 시퀀스 자료형의 일반적인 특징(인덱싱, 슬라이싱, 연결, 반복, 멤버십 테스트 등)을 지원하며, 변경이 가능한 특성에 따라 자료의 크기를 동적으로 임의 조절하거나, 내용을 치환하여 변경할 수 있다.
 
2) 리스트는 다른 객체를 직접 저장하지 않고, 객체들의 레퍼런스(Reference)만을 저장한다. (레퍼런스란 객체의 주소를 말한다.)


ref. Guido van Rossum's Python Tutorial: 3.1.4 Lists

- built-in function len()
- to nest lists (create lists containing other lists)
- object semantics

5.1 More on Lists

append(x)
extend(L)
insert(i, x)
remove(x)
pop([i])
index(x)
count(x)
sort(x)
reverse()


Stack 스택: 나중에 넣은 데이터를 먼저 꺼내도록 되어 있는 메모리 구조
Queue 큐: 먼저 넣은 데이터를 먼저 꺼내도록 되어 있는 메모리 구조
    - push 연산 (append 메쏘드) &pop 연산 (pop 메쏘드)


filter(function, sequence)

map(function, sequence)

reduce(function, sequence)


ref. NodeBox | Lists

choice(list) 
    = list[random(len(list)]