Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
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 가이드입니다
10 changes: 8 additions & 2 deletions SpartSwiftGrammer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,12 @@
7F01AB392E554A7500A600E3 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = "";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N94CS4N6VR;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_HARDENED_RUNTIME = NO;
PRODUCT_BUNDLE_IDENTIFIER = io.Roy.SpartSwiftGrammer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 6.0;
};
Expand All @@ -270,9 +273,12 @@
7F01AB3A2E554A7500A600E3 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = "";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = N94CS4N6VR;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_HARDENED_RUNTIME = NO;
PRODUCT_BUNDLE_IDENTIFIER = io.Roy.SpartSwiftGrammer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 6.0;
};
Expand Down
31 changes: 31 additions & 0 deletions SpartSwiftGrammer/Sources/Clouser/SumClosure.swift
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)
}
}
Copy link

Choose a reason for hiding this comment

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

첫번째 문제가 빠진 것 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@minneee 추가 했습니다 !

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
}
}

18 changes: 18 additions & 0 deletions SpartSwiftGrammer/Sources/Main/main.swift
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)