This file contains hidden or 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
| initials :: [(String, String)] -> [String] | |
| initials xs = [pickup first last | (first, last) <- xs] | |
| where pickup first last = [head first] ++ ". " ++ [head last] ++ "." |
This file contains hidden or 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
| chain :: Integer -> [Integer] | |
| chain 1 = [1] | |
| chain n | |
| | even n = n : chain (n `div` 2) | |
| | odd n = n : chain (n * 3 + 1) | |
| numLongList :: Int | |
| numLongList = length (filter isLong (map chain [1..1000])) | |
| where isLong xs = length xs > 15 |
This file contains hidden or 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
| func chain(num:Int) -> [Int] { | |
| guard num > 0 else { | |
| fatalError("can not calculate with 0") | |
| } | |
| switch num { | |
| case 1: | |
| return [1] | |
This file contains hidden or 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
| lucky :: Int -> String | |
| lucky 7 = "LUCKY NUMBER SEVEN!!" | |
| lucky x = "SORRY," ++ show x ++ " YOU'RE OUT OF LUCK!!" | |
| sayMe :: Int -> String | |
| sayMe 1 = "One" | |
| sayMe 2 = "Two" | |
| sayMe 3 = "Three" | |
| sayMe 4 = "Four" |
This file contains hidden or 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/UIKit.h> | |
| IB_DESIGNABLE | |
| @interface CustomView : UIView | |
| @property (nonatomic) IBInspectable CGFloat lineWidth; | |
| @property (nonatomic) IBInspectable CGFloat dotWidth; | |
| @property (nonatomic) IBInspectable CGFloat dotInterval; | |
| @property (nonatomic) IBInspectable UIColor *lineColor; | |
| @property (nonatomic) IBInspectable BOOL *isThinLine; |
This file contains hidden or 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
| [[NSUserDefaults alloc] initWithSuiteName:<#App Groups Name#>]; |
This file contains hidden or 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 = [0,1,2,3,4,5] | |
| var sum = { (a:Int, b:Int) -> Int in | |
| a + b | |
| } | |
| var odd = { (number:Int) -> Bool in | |
| number % 2 != 0 | |
| } |
This file contains hidden or 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 filePath = NSBundle.mainBundle().pathForResource(<#Filename#>, ofType:"plist" ) | |
| let dic = NSDictionary(contentsOfFile:filePath!) |
This file contains hidden or 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
| /** | |
| * xibからviewオブジェクトを取り出す | |
| */ | |
| extension UIView { | |
| class func loadFromNibNamed(nibNamed: String, bundle : NSBundle = NSBundle.mainBundle()) -> UIView! { | |
| return UINib(nibName: nibNamed, bundle: bundle).instantiateWithOwner(nil, options: nil)[0] as? UIView | |
| } | |
| class func screenCapture(view: UIView) -> UIImage { | |
This file contains hidden or 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 UIStoryboard { | |
| /** | |
| StoryboardからUIViewControllerを取り出す | |
| :param: storyboardName 取り出すstoryboard名 | |
| :param: viewControllerName 取り出したいviewcontroller名 | |
| :returns: viewController | |
| */ | |
| class func instantiateViewController(storyboardName: String, viewControllerName: String) -> UIViewController { |