Skip to content

Instantly share code, notes, and snippets.

@animato

animato/2.exs Secret

Last active February 18, 2023 13:51
Show Gist options
  • Save animato/85e16b17e635b22977238e685b1e33cb to your computer and use it in GitHub Desktop.
Save animato/85e16b17e635b22977238e685b1e33cb to your computer and use it in GitHub Desktop.
# 처음 배우는 엘릭서 프로그래밍 연습문제
# 2-1 다음 중 매칭에 성공하는 식은 무엇일까?
a = [1, 2, 3] # 성공
a = 4 # 성공
4 = a # 성공. 단, a 가 4로 할당되어 있다면
[a, b] = [1, 2, 3] # 실패
a = [[1, 2, 3]] # 성공
[a] = [[1, 2, 3]] # 성공
[[a]] = [[1, 2, 3]] # 실패
# 2-2 다음 중 매칭에 성공하는 식은 무엇인가?
[a, b, a] = [1, 2, 3] # 실패
[a, b, a] = [1, 1, 2] # 실패
[a, b, a] = [1, 2, 1] # 성공. a = 1, b = 2
# 2-3 변수 a에 값 2가 바인딩 되어 있다면 다음 중 매칭에 성공하는 식은 무엇인가?
[a, b, a] = [1, 2, 3] # 실패
[a, b, a] = [1, 1, 2] # 실패
a = 1 # 1로 새로 바인딩 됨
^a = 2 # 성공
^a = 1 # 실패
^a = 2 - a # 실패
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment