list (type) (타입 list)
원본: Computation Layer 문서(list (type))
항목들의 배열(List)을 나타낸다.
원문(영어) 보기
Represents a list of items.
속성(Attributes)
length
배열을 받아 그 길이를 숫자로 돌려준다.
원문(영어) 보기
Takes a List and returns its length as a number.
# Create a list using the values in column 1 of the table. ▷ 표의 1열 값으로 배열을 만든다. X = table.columnNumericValues(1) ▶ 변수 X는table.columnNumericValues(1), 즉 표의 1열 전체의 숫자배열(numberList)로 한다.columnNumericValues(열)은 그 열의 각 셀을 계산한 값을 숫자배열로 돌려준다. # Use CL to display a dynamic note. ▷ CL로 동적인 메모를 표시한다. content: # When the table is empty (list length = 0), # tell the student to enter some x values. ▷ 표가 비어 있으면(배열 길이 = 0) 학생에게 x 값을 입력하라고 안내한다. when length(X) = 0 "Enter some values for `x`." # After at least one point has been entered, display # a new set of instructions is displayed along with # the number of points entered, represented by length(X). ▷ 점이 하나 이상 입력되면, length(X)로 나타낸 입력한 점의 수와 함께 새로운 안내를 보여 준다. otherwise "You have entered `${length(X)}` points. What do you think this graph will look like? Use the sketch tool if it helps with your thinking." ▶ 메모의 내용(content)은length(X) = 0이면 "Enter some values for `x`."(x 값을 입력하시오.), 그렇지 않으면 "You have entered `${length(X)}` points."(입력한 점은length(X)개이다.) 다음에 빈 줄을 두고 "What do you think this graph will look like?"(이 그래프는 어떤 모양일 것 같은가?), 다시 빈 줄을 두고 "Use the sketch tool if it helps with your thinking."(생각에 도움이 되면 스케치 도구를 쓰시오.)로 한다.length(…)는 배열을 받아 길이를 숫자로 돌려주고,${ }는 글자 안에 변수의 값을 끼워 넣는 표기이다.when은 조건을 차례로 확인해 처음 맞는 값을 쓰고,content는 메모에 직접 적은 글을 덮어쓴다.
elementAt
배열과 번호를 받아 그 번호(1부터 센다)의 원소를 돌려준다.
원문(영어) 보기
Takes a List and an index, and returns the element of the list at that index (starts with 1)
# Create variables for the distances from the center # for each of the first 5 elements in the history list "distance" ▷ 기록 배열 "distance"의 처음 5개 원소에 대해 중심으로부터의 거리 변수를 만든다. d1 = button.history("distance").elementAt(1) ▶ 변수 d1은 버튼이 "distance"라는 이름으로 기록한 값들의 배열에서 1번째 원소(button.history("distance").elementAt(1))로 한다.history("이름")은capture로 기록한 값들의 기록 전체를 가져오고,elementAt(번호)는 배열과 번호를 받아 그 번호(1부터 센다)의 원소를 돌려준다. d2 = button.history("distance").elementAt(2) ▶ 변수 d2는 기록 배열의 2번째 원소(button.history("distance").elementAt(2))로 한다. d3 = button.history("distance").elementAt(3) ▶ 변수 d3는 기록 배열의 3번째 원소(button.history("distance").elementAt(3))로 한다. d4 = button.history("distance").elementAt(4) ▶ 변수 d4는 기록 배열의 4번째 원소(button.history("distance").elementAt(4))로 한다. d5 = button.history("distance").elementAt(5) ▶ 변수 d5는 기록 배열의 5번째 원소(button.history("distance").elementAt(5))로 한다. # Set the cellContent for each row using the variables d1-5 # Conditionally set the nth cell to blank before the nth attempt ▷ 변수 d1~d5로 각 행의 cellContent를 정한다. n번째 셀은 n번째 시도 전에는 비워 둔다. cellContent(1,2): when button.pressCount < 1 "" otherwise "${d1}" ▶ 표의 1행 2열 셀의 내용(cellContent)은button.pressCount가 1보다 작으면 빈 글자, 그렇지 않으면 "${d1}"로 한다.cellContent(행, 열)은 지정한 셀의 내용을 정한다.pressCount는 행동 버튼이 눌린 횟수를 알려 주고,${ }는 글자 안에 변수의 값을 끼워 넣는 표기이다.when은 조건을 차례로 확인해 처음 맞는 값을 쓴다. cellContent(2,2): when button.pressCount < 2 "" otherwise "${d2}" ▶ 표의 2행 2열 셀의 내용(cellContent)은 버튼이 눌린 횟수(button.pressCount)가 2보다 작으면 빈 글자, 그렇지 않으면 "${d2}"로 한다. cellContent(3,2): when button.pressCount < 3 "" otherwise "${d3}" ▶ 표의 3행 2열 셀의 내용(cellContent)은 버튼이 눌린 횟수(button.pressCount)가 3보다 작으면 빈 글자, 그렇지 않으면 "${d3}"로 한다. cellContent(4,2): when button.pressCount < 4 "" otherwise "${d4}" ▶ 표의 4행 2열 셀의 내용(cellContent)은 버튼이 눌린 횟수(button.pressCount)가 4보다 작으면 빈 글자, 그렇지 않으면 "${d4}"로 한다. cellContent(5,2): when button.pressCount < 5 "" otherwise "${d5}" ▶ 표의 5행 2열 셀의 내용(cellContent)은 버튼이 눌린 횟수(button.pressCount)가 5보다 작으면 빈 글자, 그렇지 않으면 "${d5}"로 한다. # Display the most recent element of the history list on row 6. # note: in this case it could also be attained using lastValue, # but elementAt is used here to showcase a dynamic index. ▷ 기록 배열의 가장 최근 원소를 6행에 표시한다. 참고: 이 경우 lastValue로도 얻을 수 있지만, 동적인 번호를 보여 주려고 elementAt을 썼다. cellContent(6,2): when button.pressCount < 6 "" otherwise "${button.history("distance").elementAt(button.pressCount)}" ▶ 표의 6행 2열 셀의 내용(cellContent)은 버튼이 눌린 횟수(button.pressCount)가 6보다 작으면 빈 글자, 그렇지 않으면 "${button.history("distance").elementAt(button.pressCount)}"로 한다.