Skip to content

Instantly share code, notes, and snippets.

View vukcevich's full-sized avatar

Marijan Vukcevich vukcevich

  • Huntington Beach, California
View GitHub Profile
@vukcevich
vukcevich / Binary-Search-Tree-AddNode.playground
Created March 29, 2018 16:48
Binary Search Tree -- example
import UIKit
class NodeTree<T: Comparable> {
var key: T?
var leftNode:NodeTree?
var rightNode: NodeTree?
init(key:T, leftChild: NodeTree?, rightChild: NodeTree?) {
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@vukcevich
vukcevich / Anonymous-Class-In-Swift.playground
Created October 10, 2017 15:51
Anonymous class in Swift - equivalent techniques
//: Playground - noun: a place where people can play
import UIKit
var str = "Anonymous Class in Swift"
//https://stackoverflow.com/questions/24408068/anonymous-class-in-swift
//There is no equivalent syntax.
//Regarding equivalent techniques, theoretically you could use closures and define structs and classes inside them.
@vukcevich
vukcevich / Swift-Enums-Types-Test1.playground
Created October 6, 2017 16:11
Swift Enums as Result Type --
//: Playground - noun: a place where people can play
import PlaygroundSupport
import UIKit
import Foundation
PlaygroundPage.current.needsIndefiniteExecution = true
URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)
@vukcevich
vukcevich / Recursion-with-binary-tree.playground
Created September 20, 2017 16:41
Swift -- recursion with binary tree
import UIKit
//Reference:
//https://medium.com/@Dougly/recursion-with-a-binary-tree-swift-3-748bbefc2cec
//Using Loop
func countDownLoop(from number: Int) {
var i = number
while i > 0 {
print(i)
@vukcevich
vukcevich / StringPatternMatch.playground
Last active September 20, 2017 16:44
Swift - find pattern that matches input pattern string
import UIKit
//Find matching pattern string as per input 'pattern' string
//****Input:
//var arStr = ["abbba"] //test 1
//var arStr = ["bbbaaa", "baaaa"]
//var arStr = ["bbbaaa", "baaaa", "abbbc", "abbba"]
//: Playground - noun: a place where people can play
import UIKit
//Article:
//https://www.raywenderlich.com/144083/swift-algorithm-club-swift-linked-list-data-structure
//Use Generics
public class Node<T> {
@vukcevich
vukcevich / Higher-Order-Functions-Swift.playground
Created September 6, 2017 19:16
Swift -- map / filter / reduce / flatMap functions - how to write shorter version - good reference point
//: Playground - noun: a place where people can play
import UIKit
//Swift --- Map -- Filter --- Reduce --- FlatMap
//An example how to write these functions in shorter form:
var HPs = [50, 60, 70]
//: Playground - noun: a place where people can play
import Foundation
import UIKit
//As reference:
//https://spin.atomicobject.com/2015/03/24/evaluate-string-expressions-ios-objective-c-swift/
/**
NSExpression
@vukcevich
vukcevich / RecursiveFunctions.playground
Created August 16, 2017 18:52
Recursion - recursive functions - swift.
/*
Things to 'remember' about recursion:
--- you can call a function inside of itself
--- you always have at least "ONE BASE CASE" in order to prevent the function calling itself infinite times.
*/
func fibonacci(_ i: Int) -> Int {
if i <= 2 {
return 1