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
let numbers = Array(1...20) | |
func isEven(x: Int) -> Bool { | |
return x % 2 == 0 | |
} | |
func square(x: Int) -> Int { | |
return x * x | |
} |
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
let numbers = Array(1...20) | |
var sum = 0 | |
for val in numbers { | |
if val % 2 == 0 { | |
sum += (val * val) | |
} | |
} |
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
import UIKit | |
let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
//var sum = 0 | |
// | |
//for number in numbers { | |
// sum += number | |
//} |
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
import UIKit | |
let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
//var newNumbers = [Int]() | |
// | |
//for number in numbers { | |
// let newNumber = number * number | |
// newNumbers.append(newNumber) | |
//} |
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
import UIKit | |
let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
//var evenNumbers = [Int]() | |
// | |
//for number in numbers { | |
// if (number % 2 == 0) { | |
// evenNumbers.append(number) | |
// } |
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
// Functional Programming: Find avg. of two numbers | |
let findAverage: (Float, Float) -> Float = { x, y in | |
return (x + y) / 2 | |
} | |
let firstValue:Float = 24.0 | |
let secondValue:Float = 7.0 | |
let avg = findAverage(firstValue, secondValue) |
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
import Foundation | |
var str = "Hello, playground" | |
extension String { | |
func vowelConsonantCount() -> (vowels: Int, consonants: Int) { | |
var numOfVow = 0, numOfCon = 0 | |
self.lowercased().forEach { (char) in | |
if "aeiou".contains(char) { numOfVow += 1 } |
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
import Foundation | |
var str = "Hello, playground" | |
extension String { | |
var numberOfVowels: Int { | |
var numOfVow = 0 | |
self.lowercased().forEach { (char) in | |
if "aeiou".contains(char) { | |
numOfVow += 1 |
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
// | |
// UserViewModel.swift | |
// MVVM | |
// | |
// Created by Milan Panchal on 19/03/20. | |
// Copyright © 2020 Jeenal Infotech. All rights reserved. | |
// | |
import UIKit |
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
// 20200320153014 | |
// https://randomuser.me/api/?results=20 | |
{ | |
"results": [ | |
{ | |
"gender": "male", | |
"name": { | |
"title": "Mr", | |
"first": "Victor", |