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 | |
import UIKit | |
func unallowedCharacter(word: String, alert: Bool) -> AnyObject { | |
var arrayOfString = Array(word.characters) | |
var containsUnallowedCharacter = false | |
for i in 0...arrayOfString.count - 1 { | |
var currentCharacter: String = String(arrayOfString[i]).lowercaseString |
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
class Calculator { | |
let first: Double | |
let second: Double | |
init(first: Double, second: Double){ | |
self.first = first | |
self.second = second | |
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 | |
/* Randomly choose if number of letter, then randomly give | |
back a value */ | |
func randomCharacter() -> String? { | |
let numbers = [0,1,2,3,4,5,6, 7, 8, 9] | |
let letters = ["A","B","C","D","E","F"] | |
let numberOrLetter = arc4random_uniform(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
import 'qsmap.dart'; | |
// An example using the helper 'qsmap.dart' | |
void submitAction(MouseEvent event) { | |
List parameters = ["name", "email", "body"]; | |
String name; | |
String email; | |
String body; |
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 class Human { | |
private var firstName: String? | |
private var lastName: String? | |
private var age: Int? | |
// INITIALIZERS | |
public init(_ firstName: String?, _ lastName: String?, _ age: Int?) { | |
self.firstName = firstName | |
self.lastName = lastName |
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
fn linear_search<T: Ord>(vec: &Vec<T>, key: &T) -> Option<usize> { | |
let mut result: Option<usize> = None; | |
for (i, n) in vec.into_iter().enumerate() { | |
if n == key { | |
result = Some(i) | |
} | |
}; | |
result |
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 executeOperation<A: Numeric>(_ op: @escaping (_ a: A, _ b: A) -> A) -> (_ n1: A, _ n2: A) -> A { | |
return { n1, n2 in | |
op(n1, n2) | |
} | |
} | |
func subtract(_ n1: Int, _ n2: Int) -> Int { | |
return n1 - n2 |
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
use std::collections::HashMap; | |
trait StringToF32 { | |
fn to_f32(self) -> f32; | |
} | |
impl StringToF32 for String { | |
fn to_f32(self) -> f32 { | |
self.parse::<f32>().unwrap() | |
} |
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
use std::collections::HashMap; | |
use std::hash::Hash; | |
pub struct BidirectionalMap<K, V> { | |
right_to_left: HashMap<K, V>, | |
left_to_right: HashMap<V, K> | |
} | |
impl<K,V> BidirectionalMap<K, V> | |
where K: Hash + Eq + Clone, |
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
extension Int { | |
var asDouble: Double { | |
return Double(self) | |
} | |
} | |
extension Double { | |
var halve: Double { | |
return self / 2 | |
} |
OlderNewer