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
#if TARGET_OS_IPHONE | |
@interface UIView (RecursiveDescription) | |
#else | |
@interface NSView (RecursiveDescription) | |
#endif | |
#ifdef DEBUG | |
- (NSString*)_recursiveDescription; | |
#endif | |
@end |
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
NSString*(^__block __weak r)(id,int)=^(id v,int d){NSMutableString*m,*l;m=[NSMutableString string];l=[NSMutableString string];for(id _ in [v subviews])[m appendString:r(_,d+1)];for(int i=0;i<d;i++)[l appendString:@" | "];return[NSString stringWithFormat:@"%@%@\n%@",l,[v description], m];}; | |
NSLog(@"\n%@", r(<#target_view#>, 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
module Main where | |
main = print $ calc cs | |
cs = "3 4 + 5 2 - * 4 2 / +" | |
calc :: String -> Float | |
calc = calc' [] . words | |
calc' :: [Float] -> [String] -> Float |
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
module Main where | |
main = print $ calc cs | |
cs = "3 4 + 5 2 - * 4 2 / +" | |
calc :: String -> Float | |
calc = head . foldl calc' [] . words where | |
calc' :: [Float] -> String -> [Float] | |
calc' [x] [] = [x] |
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
module Main where | |
main = putStrLn $ unlines $ map (show) $ primes 1000000 | |
primes :: Int -> [Int] | |
primes max | |
| max < 2 = error "No primes" | |
| otherwise = erat [] [2..max] | |
where | |
erat :: [Int] -> [Int] -> [Int] |
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
module Main where | |
import System.Random | |
import Data.Maybe | |
import Data.Bits | |
import Data.List | |
import Data.Char | |
main = do | |
gen <- getStdGen |
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
# Const | |
CODE_NUMS = 100 | |
CODE_LENGTH = 8 | |
AVAILABLE_CHARS = ('A'..'Z').to_a.delete_if{|c| c == 'O'} | |
AVAILABLE_CHARS_NUM = AVAILABLE_CHARS.length | |
# Throw random nums to suck | |
code_suck = [] | |
(CODE_NUMS*2).times do | |
buff = [] |
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
require 'benchmark' | |
ary = [] | |
itrts = 50_000_000 | |
code_range = 1e+13.to_i...4e+13.to_i | |
itrts.times do |i| | |
ary << rand(code_range) | |
end | |
puts Benchmark::CAPTION |
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
module Main where | |
import Data.List | |
import Data.Char | |
import Test.Hspec | |
data Hand = FC | FH | TC | TP | OP | |
data Suit = S | H | D | C deriving (Read, Show) | |
data Rank = RA | R2 | R3 | R4 | R5 | R6 | R7 | R8 | R9 | RT | RJ | RQ | RK deriving (Show, Eq, Ord, Enum) | |
type Card = (Suit, Rank) |
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
module Main where | |
import Data.List | |
import Data.Char | |
import qualified Data.Set as Set | |
type Gem = Int | |
gems = "abbbbcddddeefggg" | |
princess = "eagcdfbe" |
OlderNewer