Skip to content

김주희) 필수과제 + 도전문제 2,3번 풀이입니다.#5

Open
coduhee wants to merge 31 commits into
mainfrom
juhee
Open

김주희) 필수과제 + 도전문제 2,3번 풀이입니다.#5
coduhee wants to merge 31 commits into
mainfrom
juhee

Conversation

@coduhee
Copy link
Copy Markdown
Collaborator

@coduhee coduhee commented Jan 7, 2026

No description provided.

Comment thread juhee/main.swift Outdated
Comment on lines +37 to +38
var result2 = numbers2.filter { $0 % 2 == 0}
var result3 = result2.map { String($0) }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고차함수 처음 학습하셨다고 하셨는데 잘 활용해주신 것 같아요!

(아시겠지만..!) 요기 두 변수 result2, result3은 각각 필터링 된 배열, 매핑된 배열이 할당되는 녀석들이고 후에 바뀌지 않으니 let으로 선언해주셔도 좋았을 것 같습니당ㅎㅎ

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다. 예린님 🤩
생각 못했던 부분인데 참고해서 수정해보겠습니다~!!

Comment thread juhee/main.swift Outdated
let numbers2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

var result2 = numbers2.filter { $0 % 2 == 0}
var result3 = result2.map { String($0) }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

과제에서 "주어진 입력값을 고차함수를 체이닝하여 주어진 출력값이 나오도록 구현해주세요."
라고 요구사항이 있어서 마지막 출력값에 고차함수들을 .으로 이어서 연속으로 호출해주셨으면 더 좋았을 것 같습니당 👍

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

체이닝 개념이 전혀 없었어서 문제 의도파악을 못했던것 같습니다ㅠㅠ 추가학습 후 수정하였습니다. 예슬님 너무 감사합니다 🥹

Comment thread juhee/main.swift Outdated
func myMap (a: [Int], operation: (Int) -> String) -> [String] {
var result = [String]()
for i in a {
result.append(String(i))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉 파라미터로 받은 클로저 operation가 안 쓰이고 있는 것 같습니다 😯

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

애를 불러놓고 쓰질 않았네요.... 함수의 매개변수로 클로저를 쓰는 부분이 넘 어려운거같더니 여기서 걸리네요ㅠㅠ 예슬님 리뷰해주셔서 너무 감사드려요😍 참고해서 수정하였고 덕분에 월요일 코딩 쏘우방에서 한발자국 멀어진것같아요🫶

sum 정의하는것부터 잘못되어서 수정합니다..
체이닝 활용하는 부분, 함수의 매개변수로 클로저 사용하는 부분 수정하였습니다.
@coduhee coduhee changed the title 김주희) 필수과제 1,2번 문제 풀이입니다. 김주희) 필수과제 1~4번 문제 풀이입니다. Jan 9, 2026
@coduhee coduhee changed the title 김주희) 필수과제 1~4번 문제 풀이입니다. 김주희) 필수과제 전체 문제 풀이입니다. Jan 9, 2026
coduhee added 13 commits January 9, 2026 12:32
함수의 출력값이 없을때 쓰는 -> Void는 생략이 가능하다.
result2 변수 var를 let으로 변경
체이닝 부분 줄바꿈으로 가독성 증가
 if count % 2 == 0 짝수배열일때 append하는것으로 코드 수정
문제3번 반복문 활용 부분에서 .count를 사용하여 더 직관적이고 간결하게 코드를 작성하는 방향으로 리펙토링함.
문제4번 WillSet부분에서 self.name을 name으로 작성하여도 같은결과이므로 self. 삭제
문제 3번의 나머지 코드(제네릭, 프로토콜 추가)들도 같은 방식으로 수정함
This README provides an overview of the Swift basic assignments, covering key concepts such as closures, higher-order functions, generics, protocols, and error handling.
@coduhee coduhee changed the title 김주희) 필수과제 전체 문제 풀이입니다. 김주희) 필수과제 + 도전문제 2,3번 풀이입니다. Jan 12, 2026
Updated the README to enhance clarity and structure.
Updated the README to enhance project structure and details.
3-1, 3-2문제를 .enumerated() 를 이용한 풀이로 리펙토링
3-3, 3-4문제는 기존 코드에서 [1, 3, 5], ["가", "다", "마"] 출력되도록 조건문 수정
배열을 선언과 동시에 초기화하도록 수정,
if else 중첩문을 guard로 수정
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants