This file contains 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
package com.codility.tasks; | |
/* | |
Negate a negative based binary (base -2) using Two's Complement Annotation. | |
Given a base -2 number splitted into a primitive array of ints (int[]), return it's negation. | |
EXAMPLES: | |
INPUT: [0,1,0,0,1,1,1] // Decimal 39. | |
OUTPUT: [1,0,1,1,0,0,1] // Decimal -39. | |
This file contains 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
/// The function called after visiting `ClassDeclSyntax` and its descendents. | |
/// - node: the node we just finished visiting. | |
open func visitPost(_ node: ClassDeclSyntax) {} |
This file contains 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
override func visit(_ node: ClassDeclSyntax) -> SyntaxVisitorContinueKind { | |
// Do something with a class node | |
return .visitChildren | |
} | |
override func visit(_ node: ExtensionDeclSyntax) -> SyntaxVisitorContinueKind { | |
// Do something totally different with an extension node | |
return .visitChildren | |
} |
This file contains 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
/// Visiting `ClassDeclSyntax` specifically. | |
/// - Parameter node: the node we are visiting. | |
/// - Returns: how should we continue visiting. | |
open func visit(_ node: ClassDeclSyntax) -> SyntaxVisitorContinueKind { | |
return .visitChildren | |
} |
This file contains 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
public enum SyntaxVisitorContinueKind { | |
/// The visitor should visit the descendents of the current node. | |
case visitChildren | |
/// The visitor should avoid visiting the descendents of the current node. | |
case skipChildren | |
} |
This file contains 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
[{ | |
"balance": "4675", | |
"IBAN": "NL27AAAA0352734310", | |
"currency": "EUR", | |
"id": "8ab78900f99013a", | |
"name": "Main Account", | |
"type": "main" | |
}] |
This file contains 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
struct SimpleEntry: TimelineEntry { | |
public let date: Date | |
} |
This file contains 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
struct AccountEntry: TimelineEntry { | |
public let date: Date | |
public let product: Product | |
} |
This file contains 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
enum ProductType { | |
case main, secondary | |
} | |
struct Product: Identifiable { | |
let id: String | |
let name: String | |
let balance: Double | |
let iban: String | |
let type: ProductType |
This file contains 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
struct Provider: TimelineProvider { | |
public typealias Entry = SimpleEntry | |
public func snapshot(with context: Context, completion: @escaping (SimpleEntry) -> ()) { | |
/* implementation */ | |
} | |
public func timeline(with context: Context, completion: @escaping (Timeline<Entry>) -> ()) { | |
/* implementation */ | |
} |
OlderNewer