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 MyFib where | |
| fibonacci :: Integer -> Integer | |
| fibonacci n | n == 0 = 0 | |
| | n == 1 = 1 | |
| | n > 0 = helper 0 1 n | |
| | n < 0 = ((-1) ^ (-n+1)) * helper 0 1 (-n) | |
| helper acc1 acc2 0 = acc1 | |
| helper acc1 acc2 n = helper (acc2) (acc2 + acc1) (n - 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
| fibonacci :: Integer -> Integer | |
| fibonacci n | n < 0 = ((-1) ^ (-n+1)) * fibonacci(-n) | |
| | n == 0 = 0 | |
| | n == 1 = 1 | |
| | n > 0 = fibonacci(n - 1) + fibonacci(n - 2) |
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 @program.archived? && !request.path.match(/archive/).present? | |
| redirect_to @program.is_videoblog? ? \ | |
| archived_videoblogs_path(@program) : \ | |
| archived_programs_path(@program), status: :moved_permanently | |
| 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
| def include_path?(options) | |
| return false unless request | |
| url_string = url_for(options) | |
| if url_string.index("?") | |
| request_uri = request.fullpath | |
| else | |
| request_uri = request.path |
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
| qsort :: Ord a => [a] -> [a] | |
| qsort [] = [] | |
| qsort (a:xs) = let | |
| helper [] y l = y : qsort l | |
| helper (k:ks) y l | k <= y = helper ks k (y : l) | |
| | otherwise = helper ks y (k : l) | |
| in helper xs a [] |
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 Data.List | |
| change :: (Ord a, Num a) => a -> [[a]] | |
| change a = let | |
| coins = [2,3,7] | |
| unique = reverse . nub . reverse | |
| helper a = [ filter (/=0) [x, y, z] | x <- 0 : coins, y <- 0 : coins, z <- 0 : coins, x + y + z == a ] | |
| in unique $ helper a |
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 Odd where | |
| data Odd = Odd Integer | |
| deriving (Eq, Show) | |
| instance Enum Odd where | |
| toEnum :: Int a -> Odd a | |
| toEnum x = Odd x | |
| fromEnum :: a -> 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
| perms [] = [[]] | |
| perms list = let | |
| del x [] = [] | |
| del x (y:ys) = if x /= y then y : del x ys else del x ys | |
| in concatMap (\x -> map (x:) $ perms $ del x list ) list |
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 ApplicationHelper | |
| FILTER_FIELD_TMPL = %q( | |
| <div class="filter-field"> | |
| <form method="get" action="%{action}"> | |
| <div class="form-group input-group"> | |
| <input name="%{name}" type="text" class="form-control input-lg" placeholder="%{placeholder}" value="%{value}"> | |
| <div class="input-group-btn"> | |
| <button type="submit" class="btn btn-default btn-lg icon-search"></button> | |
| </div> |
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
| irb(main):008:0> req = Laximo.oem.find_vehicle_by_wizard('BMW201402', "") | |
| *** | |
| *** DEPRECATION WARNING! Method `find_vehicle_by_wizard` is deprecated and will not support in the future | |
| *** | |
| opening connection to ws.laximo.net:443... | |
| opened | |
| starting SSL for ws.laximo.net:443... | |
| SSL established | |
| <- "POST /ec.Kito.WebCatalog/services/Catalog.CatalogHttpSoap11Endpoint/ HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: LaximoRuby [0.4.2]\r\nContent-Type: text/xml; charset=UTF-8\r\nSoapaction: \"http://WebCatalog.Kito.ec\"\r\nConnection: close\r\nHost: ws.laximo.net\r\nContent-Length: 612\r\n\r\n" | |
| <- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<SOAP-ENV:Envelope SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\nxmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\nxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\">\n <SOAP-ENV:Bo |