
ex) 논리 연산자가 뭐예요? 왜 써요? 종류는요?function: A named set of commands that can be run whenever needed. 필요할 때마다 실행될 수 있는 이름 붙여진 명령어들의 집합
Functions are "self contained" modules of code that accomplish a specific task. 함수는 특별한 일을 성취하기 위한 독립된 코드 모듈이다.
하나 이상의 논리적인 기능을 수행하기 위한 명령어들의 집합! Every day, you perform a range of tasks automatically,
without thinking about what you're doing.
Even a simple task, like tying your shoe, took time to atutomate.
You learned to do it using a sequence of steps.
To tie your shoe, you do the following:
loop
swoop
pull
In programming, a function allows you to name set of commands,
which you can then run any time you want.
func tieMyshoe() {
loop
swoop
pull
}
After you define your function, call it by name to run its commands.
To define a function, use func and choose a name. Always follow a function name with (). And give your function its behavior by adding commands inside the curly braces '{}'.
ex) func tieMyshoe() {
loop()
swoop()
pull()
}
Functions part words
a number of different things of the same general kind.to spend enough time to do something well or carefullyThe process of combining small parts of an application to solve a larger problem.achieving maximum productivity with minimum wasted effort or expense.in or to a lower position than someone or something, under someone or somethingin a way that shows all the characteristics that you would expect from the stated person, thing, or group 사람, 사물, 조직에서 시작할 때 예상할 수 있는 특징을 보여주는 방식(일반적으로)To provide the explicit value or behavior of a newly created peice of code, such as function, variable, or custom type. For example, you define a function by providing a set of commands within the function to tell it what to do. 함수나 변수, 사용자가 정의한 유형과 같이 새로 생성된 코드의 명확한 값이나 행위를 제공하는 것. 예를 들면, 함수 안에 명령어 집합을 제공함으로서 함수를 정의하여 그것이 무엇을 해야하는지 지시할 수 있다.(정의하다)clear and exact 명확하고 정확한To call a function in code is to instruct that function to run, performing the actions defined inside it. For example, calling the moveForward() function performs its actions that result in a forward move. 코드에서 함수를 호출하는 것은 함수를 실행하고, 그 안에 정의된 행동을 수행하기 위해 지시하는 것이다. 예를 들면, moveForward() 함수를 호출하는 것은 그것이 결과적으로 앞으로 움직이는 행위를 수행하도록 한다.(호출하다)A repeating set of circumstances or data. 상황이나 데이터의 반복되는 집합a fact or event that makes a situation the way it is 상황을 있는 그대로 만드는 사실이나 사건(상황)from one's first look; immediately 한 눈에 보자마자, 즉각적으로to shine, reflect light, or sparkle으로 섬광을 의미한다! 번쩍! 하자마자! 이런 느낌으로 이해하면 될 듯!The process of breaking a large problem into smaller, more manageable pieces. 큰 문제를 작고 더 다루기 쉬운 부분으로 분해하는 과정이다.예제 문제: turnRight() 만 사용하여 turn to right 하기
func turnRight() {
turnLeft()
turnLeft()
turnLeft()
}
Functions(함수)는 필요할 때마다 불러서 사용할 수 있도록 이름지어진 명령어들의 집합이다.
ex) 오른쪽으로 회전하는 작업을 수행하기 위한 함수!
func turnRight() { -> moveRight 라는 이름의 함수를 정의
turnLeft()
turnLeft()
turnLeft() -> 왼쪽 방향으로 세 번 회전하는 명령어 추가
}
추가적으로, 함수를 정의하기 위해서는 func를 사용하고 이름을 선택해야 한다. 함수는 항상 이름 뒤에 괄호'()'가 있어야 하고, 기능을 부여하기 위해서는 중활호'{}' 안에 명령어들을 추가해야 한다
Composition과 Decomposition의 차이
composition은 큰 문제를 해결하기 위해 함수들을 결합하는 것이고, decomposition은 큰 문제를 작고, 더 다루기 쉬운 조각들로 분해하는 것이다.
22.08.05 TIL 끝!
썸네일은 Banner Maker로 제작하였습니다.