Other Functions (그 밖의 함수)
원본: Computation Layer 문서(Other Functions)
앞의 구역들에 깔끔하게 들어가지 않는 함수들이다.
원문(영어) 보기
Here are some functions which don't fit cleanly into one of the above sections.
mergeSketches
다른 스케치들로 하나의 스케치를 만든다.
원문(영어) 보기
Create a sketch from other sketches.
# Combines the current stroke with the rest of # the sketch to create a layer that appears in # real time. ▷ 현재 획을 스케치의 나머지와 합쳐, 실시간으로 나타나는 레이어를 만든다. background: sketchLayer(mergeSketches(sketch1.sketch,sketch1.currentStroke)) ▶ 그림판의 배경(background)은sketchLayer(mergeSketches(sketch1.sketch,sketch1.currentStroke)), 즉 지금까지의 스케치와 그리는 중인 획을 합친 스케치로 만든 레이어로 한다.background는 그래프나 그림판의 배경 레이어를 정하고,mergeSketches(…)는 다른 스케치들로 하나의 스케치를 만들며,sketchLayer(…)는 스케치로 레이어를 만든다.
length
배열(List)을 받아 그 길이를 숫자로 돌려준다.
원문(영어) 보기
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는 메모에 직접 적은 글을 덮어쓴다.
numericValue
latex 글자를 받아 가능하면 숫자로 계산한다. 계산하지 못하면 NaN을 돌려준다.
원문(영어) 보기
Takes a latex string, and evaluates it to a number, if possible. Returns NaN if it fails
# Get the latex string from the expression input component # "orderedPairInput". Create an orderedPair object using # parseOrderedPair and then assign that object to the # Computation Layer variable "myPair". ▷ 수식 답변 구성요소 "orderedPairInput"에서 latex 글자를 가져온다. parseOrderedPair로 orderedPair 객체를 만들고, 그 객체를 Computation Layer 변수 "myPair"에 정한다. myPair = parseOrderedPair(orderedPairInput.latex) ▶ 변수 myPair는parseOrderedPair(orderedPairInput.latex), 즉 수식 답변 orderedPairInput에 입력한 latex로 만든 순서쌍 객체로 한다.parseOrderedPair(…)는 latex 글자(예: "(a,2)")를 받아 x: "a", y: "2"처럼 순서쌍 객체를 돌려주고,latex는 입력한 식의 LaTeX 글자를 가져온다. # Assign the numeric value of the x property # of the orderedPair object named "myPair" to # the calculator variable "x_last". ▷ orderedPair 객체 "myPair"의 x 속성의 숫자 값을 계산기 변수 "x_last"에 정한다. number("x_{last}"): numericValue(myPair.x) ▶ 그래프의 변수 x_{last}(number("x_{last}"))는numericValue(myPair.x), 즉 순서쌍의 x(첫 번째 원소의 latex)를 숫자로 계산한 값으로 한다.number("이름")은 그래핑 계산기 안의 변수 값을 정하고,numericValue(…)는 latex 글자를 숫자로 계산한다. # Assign the numeric value of the y property # of the orderedPair object named "myPair" to # the calculator variable "y_last". ▷ orderedPair 객체 "myPair"의 y 속성의 숫자 값을 계산기 변수 "y_last"에 정한다. number("y_{last}"): numericValue(myPair.y) ▶ 그래프의 변수 y_{last}(number("y_{last}"))는numericValue(myPair.y), 즉 순서쌍의 y(두 번째 원소의 latex)를 숫자로 계산한 값으로 한다.
conic
주어진 latex 글자로 새 conic(원뿔곡선) 객체를 만든다.
원문(영어) 보기
Create a new conic object from the provided latex string.
evaluationFrame
나중에 계산하기 위해 함수와 변수를 담아 두는 틀(frame)을 만든다.
원문(영어) 보기
Creates a frame to store functions and variables for future evaluation.
# Open an evaluation frame. ▷ 평가 틀(evaluation frame)을 연다. frame = evaluationFrame() ▶ 변수 frame은evaluationFrame()으로 만든 틀에 아래 네 개의.define(…)을 이어 붙인 것으로 한다.evaluationFrame()은 나중에 계산하기 위한 함수와 변수를 담아 두는 틀(frame)을 만들고,.define(이름, 값)은 틀 안에 함수를 만들거나 변수에 숫자 값을 정해 나중에 계산할 수 있게 한다..define(…)를 점으로 이어 붙였으므로 들여쓴 줄은 앞 줄에 이어진다. # Define the variables a and b and assign their values # using the cell valuees from table1. ▷ 변수 a와 b를 정의하고, 그 값을 table1의 셀 값으로 정한다. .define(`a`,table1.cellNumericValue(1,1)) ▶ 틀 안의 변수 a는table1.cellNumericValue(1,1), 즉 table1의 1행 1열 셀의 숫자 값으로 한다.cellNumericValue(행, 열)은 그 셀을 계산한 숫자 값을 가져온다. .define(`b`,table1.cellNumericValue(1,2)) ▶ 틀 안의 변수 b는table1.cellNumericValue(1,2), 즉 table1의 1행 2열 셀의 숫자 값으로 한다. # Define the functions f and g and create them using # the cell content from table2. ▷ 함수 f와 g를 정의하고, table2의 셀 내용으로 만든다. .define(`f`,simpleFunction(table2.cellContent(1,1))) ▶ 틀 안의 함수 f는simpleFunction(table2.cellContent(1,1)), 즉 table2의 1행 1열 셀 내용으로 만든 함수로 한다.simpleFunction(…)은 latex 글자로 함수를 만들고,cellContent(행, 열)은 행 번호와 열 번호로 셀의 내용을 가져온다. 행 번호 1은 머리글 바로 아래 첫 행이다. .define(`g`,simpleFunction(table2.cellContent(1,2))) ▶ 틀 안의 함수 g는simpleFunction(table2.cellContent(1,2)), 즉 table2의 1행 2열 셀 내용으로 만든 함수로 한다. # Evaluate the function and variables from the tables # acording to the math input. ▷ 표에서 만든 함수와 변수를 수식 답변에 맞춰 계산한다. output = input1.script.frame.evaluate(this.latex) ▶ 변수 output은input1.script.frame.evaluate(this.latex), 즉 input1의 스크립트에서 만든 변수 frame으로 이 구성요소의 latex를 계산한 값으로 한다..evaluate(…)는 틀 안에서 식의 숫자 값을 구하고,구성요소.script.변수는 다른 구성요소의 스크립트에서 만든 변수의 값을 가져오는 표기이다.
substituteLatexVariable
latex 글자, 찾을 글자, 바꿀 글자를 받아 바꿔 넣은 latex를 돌려준다.
원문(영어) 보기
Takes a latex string, a search string, and a replace string - and returns the latex having made the substitution.
# Substitute in the student input for a and b. ▷ a와 b 자리에 학생의 입력을 대입한다. subA = substituteLatexVariable(input1.latex,"a",table1.cellContent(1,1)) ▶ 변수 subA는substituteLatexVariable(input1.latex,"a",table1.cellContent(1,1)), 즉 input1의 latex에서 "a"를 table1의 1행 1열 셀 내용으로 바꾼 latex로 한다.substituteLatexVariable(latex, 찾을 글자, 바꿀 글자)는 latex에서 변수를 바꿔 넣은 latex를 돌려주고,cellContent(행, 열)은 행 번호와 열 번호로 셀의 내용을 가져온다. 행 번호 1은 머리글 바로 아래 첫 행이다. subB = substituteLatexVariable(subA,"b",table1.cellContent(1,2)) ▶ 변수 subB는substituteLatexVariable(subA,"b",table1.cellContent(1,2)), 즉 subA에서 "b"를 table1의 1행 2열 셀 내용으로 바꾼 latex로 한다. # Display the evaluation only after input1 is submitted ▷ input1이 제출된 뒤에만 계산 결과를 보여 준다. eval = when input1.submitted "`${subB}=${input1.script.output}`" otherwise "Press \"Submit\" to see the evaluation." ▶ 변수 eval은input1.submitted가 참이면 "`${subB}=${input1.script.output}`"(대입한 식 = 계산 결과), 그렇지 않으면 "Press \"Submit\" to see the evaluation."(계산을 보려면 "Submit"을 누르시오.)로 한다.
글자 안의\"는 따옴표 글자 하나이고,\는 바로 뒤 글자의 뜻을 바꾸는 표시이다.submitted는 입력(또는 구성요소)이 제출되었는지를 참 또는 거짓으로 알려 준다.구성요소.script.변수는 다른 구성요소의 스크립트에서 만든 변수의 값을 가져오는 표기이고,${ }는 글자 안에 변수의 값을 끼워 넣는 표기이다.when은 조건을 차례로 확인해 처음 맞는 값을 쓴다.
countNumberUsage
latex 글자 안의 숫자 상수의 개수를 센다. countNumberUsage(latex)는 모든 숫자를 세고, 특정 숫자를 인자로 주면 그 숫자만 센다.
원문(영어) 보기
Counts numeric constants in a latex string. countNumberUsage(latex) counts all numbers, or if you provide a specific number as an argument, only that number specifically will be counted
# Create a dynamic note that displays the # total amount of 4's and numbers altogether # in the math input ▷ 수식 답변에 들어 있는 4의 개수와 전체 숫자의 개수를 보여 주는 동적인 메모를 만든다. content: "Use the number \"`4`\" four times to create an expression that equals `4`. Total numbers: `${countNumberUsage(input.latex)}` Total `4`'s: `${countNumberUsage(input.latex,4)}` Equal to `4`? ${when input.numericValue = 4 "Yes" otherwise "No"}" ▶ 메모의 내용(content)은 "Use the number \"`4`\" four times to create an expression that equals `4`."(숫자 4를 네 번 써서 4와 같은 식을 만드시오.) 다음에 빈 줄을 두고 "Total numbers: `${countNumberUsage(input.latex)}`"(전체 숫자 수), 빈 줄을 두고 "Total `4`'s: `${countNumberUsage(input.latex,4)}`"(4의 개수), 빈 줄을 두고 "Equal to `4`? ${when input.numericValue = 4 "Yes" otherwise "No"}"(4와 같은가?)로 한다.
글자 안의\"는 따옴표 글자 하나이고,\는 바로 뒤 글자의 뜻을 바꾸는 표시이다.countNumberUsage(latex)는 latex 글자 안의 숫자 상수의 개수를 세고, 특정 숫자를 인자로 주면 그 숫자만 센다. 백틱(`)으로 감싼 부분은 latex 값이다.${ }는 글자 안에 변수의 값을 끼워 넣는 표기이며 마지막 줄에서는 그 안에when … otherwise …가 다시 쓰인다.when은 조건을 차례로 확인해 처음 맞는 값을 쓰고,content는 메모에 직접 적은 글을 덮어쓴다.
formatLatex
latex 방정식과 식에 몇 가지 단순화 규칙을 적용해 보기 좋게 서식을 맞춘다.
원문(영어) 보기
Takes latex equations and expressions and applies a small set of simplification rules to format the equations and expressions nicely.
sketchLayer
스케치로 레이어를 만든다.
원문(영어) 보기
Create a layer from a sketch.
# Creates a sketch layer using only what's currently # being sketched. and displays it in the background. ▷ 지금 스케치 중인 것만으로 스케치 레이어를 만들어 배경에 표시한다. background: sketchLayer(sketch1.currentStroke) ▶ 그림판의 배경(background)은sketchLayer(sketch1.currentStroke), 즉 지금 그리는 중인 획만으로 만든 스케치 레이어로 한다.background는 그래프나 그림판의 배경 레이어를 정하고,sketchLayer(…)는 스케치로 레이어를 만들며,currentStroke는 지금 그리는 중인 획을 나타내는 스케치 객체를 가져온다.
layerStack
다른 레이어들로 레이어 묶음(stack)을 만든다.
원문(영어) 보기
Create a stack of layers from other layers.
# Creates a sketch layer using only what's currently # being sketched and a separate sketch layer out of # the existing sketch. # Stacks these layers together and displays them in # graph background. ▷ 지금 스케치 중인 것만으로 스케치 레이어를 만들고, 기존 스케치로 또 다른 스케치 레이어를 만든다. 이 레이어들을 쌓아 그래프 배경에 표시한다. background: layerStack(sketchLayer(sketch1.sketch),sketchLayer(sketch1.currentStroke)) ▶ 그래프의 배경(background)은layerStack(sketchLayer(sketch1.sketch),sketchLayer(sketch1.currentStroke)), 즉 기존 스케치로 만든 레이어와 그리는 중인 획으로 만든 레이어를 쌓은 것으로 한다.background는 그래프나 그림판의 배경 레이어를 정하고,sketchLayer(…)는 스케치로 레이어를 만들며,layerStack(…)은 여러 레이어를 쌓아 하나로 만든다.
graphLayer
그래프로 레이어를 만든다. graphLayer(g.calculatorState)처럼 쓴다.
원문(영어) 보기
Create a layer from a graph. Use it like graphLayer(g.calculatorState)