-
Notifications
You must be signed in to change notification settings - Fork 0
필수 도전 과제 2 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
필수 도전 과제 2 #2
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,34 @@ | ||
| # SpartSwiftGrammer | ||
| 내배캠 문법 주차 | ||
|
|
||
| ## 컨벤션 | ||
|
|
||
| * [공통](./Convention/Common.md) - 모든 Swift 코드에서 준수해야 하는 컨벤션입니다. | ||
|
|
||
| ## 🐈⬛ Git | ||
|
|
||
| ### 1️⃣ Git branching Strategy | ||
|
|
||
| - Origin(main branch) | ||
| - Origin(dev branch) | ||
| - Local(feature branch) | ||
|
|
||
| - Branch | ||
| - Main | ||
| - Dev | ||
| - Feature | ||
| - Fix | ||
|
|
||
| - 방법 | ||
| - 1. Pull the **Dev** branch of the Origin | ||
| - 2. Make a **Feature** branch in the Local area | ||
| - 3. Developed by **Feature** branch | ||
| - 4. Push the **Feature** from Local to Origin | ||
| - 5. Send a pull request from the origin's **Feature** to the Origin's **Dev** | ||
| - 6. In Origin **Dev**, resolve conflict and merge | ||
| - 7. Fetch and rebase Origin **Dev** from Local **Dev** | ||
|
|
||
|
|
||
| ## Commit 가이드 | ||
|
|
||
| * [Commit](./.github/.gitMessage.md) - Commit 가이드입니다 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // | ||
| // SumClosure.swift | ||
| // SpartSwiftGrammer | ||
| // | ||
| // Created by Wonji Suh on 8/20/25. | ||
| // | ||
|
|
||
| import Foundation | ||
| import LogMacro | ||
|
|
||
| final actor SumClosure { | ||
|
|
||
| static var num: Int = 3 | ||
| static var num2 : Int = 10 | ||
|
|
||
| // sum 을 호출 해서 파라메터로 전달 | ||
| static var sum: (Int, Int) -> String = { a, b in | ||
| "두 수의 합은 \(a + b) 입니다" | ||
| } | ||
|
|
||
| // 계산 하는 함수 클로져 방식 1 | ||
| static func calculate(_ operation : (Int, Int) -> String, a: Int, b: Int){ | ||
| #logDebug(operation(a, b)) | ||
| } | ||
|
|
||
| // 계산 하는 함수 클로져 방식 2 Result 추가 | ||
| static func calculate2(_ operation: (Int, Int) -> String, a: Int, b: Int) -> Result<String, Error> { | ||
| let result = operation(a, b) | ||
| return .success(result) | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
SpartSwiftGrammer/Sources/HigherOrderFunctions/HigherOrderFunctions.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // | ||
| // HigherOrderFunctions.swift | ||
| // SpartSwiftGrammer | ||
| // | ||
| // Created by Wonji Suh on 8/20/25. | ||
| // | ||
|
|
||
| import Foundation | ||
| import LogMacro | ||
|
|
||
| final actor HigherOrderFunctions { | ||
| var numbers: [Int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
|
|
||
| let numbers1 = [1, 2, 3, 4, 5] | ||
|
|
||
|
|
||
|
|
||
| func mapNumbers() { | ||
| let result = numbers1.map{ String($0) } | ||
| #logDebug(result) | ||
|
|
||
| } | ||
|
|
||
|
|
||
| func changeType(_ number: [Int] ) { | ||
| let result = number | ||
| .filter { $0 % 2 == 0} | ||
| .map { String($0)} | ||
|
|
||
| #logDebug("고차 함수 테스트", result) | ||
| } | ||
|
|
||
| func changeTypeWithMyMap(_ number: [Int] ) { | ||
| let result = myMap(number) { number in | ||
| number % 2 == 0 ? String(number) : "" | ||
| }.filter { !$0.isEmpty } | ||
| #logDebug("고차 함수 테스트 with MY MAP", result ) | ||
| } | ||
|
|
||
| func myMap<T , U>( | ||
| _ array: [T], | ||
| transform : (T) -> U) -> [U] { | ||
| var result = [U]() | ||
| for element in array { | ||
| result.append(transform(element)) | ||
| } | ||
| return result | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // | ||
| // main.swift | ||
| // SpartSwiftGrammer | ||
| // | ||
| // Created by Wonji Suh on 8/20/25. | ||
| // | ||
|
|
||
| import Foundation | ||
| import LogMacro | ||
|
|
||
| let higherOrderFunctions = HigherOrderFunctions() | ||
|
|
||
| await higherOrderFunctions.changeForinToMap() | ||
|
|
||
| await higherOrderFunctions.changeType(higherOrderFunctions.numbers) | ||
|
|
||
| await higherOrderFunctions.changeTypeWithMyMap(higherOrderFunctions.numbers) | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
첫번째 문제가 빠진 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@minneee 추가 했습니다 !