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
//Ref: https://www.swiftbysundell.com/basics/map-flatmap-and-compactmap | |
import Foundation | |
func hashTags(from string: String) -> [String] { | |
return string.components(separatedBy: .whitespacesAndNewlines) | |
.filter {string in string.starts(with: "#")} | |
} | |
print(hashTags(from: "#WWDC 2019 was #awesome #greatday")) |
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
https://www.hackerrank.com/challenges/fp-filter-positions-in-a-list/problem | |
import Foundation | |
func filterOddElements(_ list: [Int]) -> [Int] { | |
if list.count <= 1 { | |
return [] | |
} | |
let elements = list.prefix(2) |
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
https://www.hackerrank.com/challenges/fp-filter-array/problem | |
import Foundation | |
func filterList(_ upperLimit: Int, _ list: [Int]) -> [Int] { | |
if list.count <= 0 { | |
return [] | |
} | |
let element = list.first! |
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
https://www.hackerrank.com/challenges/fp-list-replication/problem | |
import Foundation | |
func printElements(_ numberOfTimes: Int, _ list: [Int]) -> [Int] { | |
if list.count <= 0 { | |
return list | |
} |
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
https://www.hackerrank.com/challenges/fp-hello-world-n-times/problem | |
import Foundation | |
func helloWorld(_ numberOfTimes: Int) { | |
if numberOfTimes <= 0 { | |
return | |
} | |
print("Hello World") |
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 | |
func add(_ x: Int, _ y: Int) -> Int { | |
return x + y | |
} | |
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
import Foundation | |
func sumOfElements(_ array: [Int], _ sum: Int) -> Int { | |
if array.count <= 0 { | |
return sum | |
} | |
let newArray = Array(array.dropFirst(1)) | |
return sumOfElements(newArray, sum + array.first!) | |
} |
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
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 |
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
Installing rmagick (2.12.2) with native extensions | |
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. | |
/home/vibin/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb | |
checking for Ruby version >= 1.8.5... yes | |
extconf.rb:107: Use RbConfig instead of obsolete and deprecated Config. | |
checking for gcc... yes | |
checking for Magick-config... no | |
Can't install RMagick 2.12.2. Can't find Magick-config in /home/vibin/.rvm/gems/ruby-1.9.3-p194/bin:/home/vibin/.rvm/gems/ruby-1.9.3-p194@global/bin:/home/vibin/.rvm/rubies/ruby-1.9.3-p194/bin:/home/vibin/.rvm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games |
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
== AddColumnPublishedToSurveys: migrating ==================================== | |
-- add_column(:surveys, :published, :boolean, {:default=>:false}) | |
rake aborted! | |
An error has occurred, all later migrations canceled: | |
Mysql2::Error: Invalid default value for 'published': ALTER TABLE `surveys` ADD `published` tinyint(1) DEFAULT 'false' | |
/home/volition/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `query' | |
/home/volition/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `block in execute' | |
/home/volition/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log' | |
/home/volition/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument' |
NewerOlder