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
| use num_traits::{Zero, One}; | |
| use std::ops::{AddAssign}; | |
| fn enumerate_generic<T>() -> impl Iterator<Item = T> | |
| where | |
| T: Clone + Zero + One + AddAssign, | |
| { | |
| let mut curr = T::zero(); | |
| std::iter::repeat_with(move || { | |
| let next = curr.clone(); |
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
| use nom::bytes::complete::*; | |
| use nom::error::ParseError; | |
| use nom::sequence::tuple; | |
| use nom::InputTakeAtPosition; | |
| use nom::{error::VerboseError, IResult}; | |
| fn main() { | |
| let a: ParseResult<()> = skip_whitespace(" hello"); | |
| println!("Parse result: {:?}", 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
| {-# LANGUAGE BangPatterns #-} | |
| module CollatzConjecture ( collatz | |
| , collatz1 | |
| , collatz2 | |
| , collatz3 | |
| , collatz4 | |
| , collatz5 | |
| ) where | |
| import Data.List (genericLength, elemIndex) |
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
| #!/usr/bin/env tclsh | |
| proc sum {k m n e} { | |
| set r 0 | |
| for {set k $m} {$k < $n} {incr k} { | |
| set r [expr {$r + [uplevel 1 [list set k $k]; uplevel 1 $e]}] | |
| } | |
| return $r | |
| } | |
| set test [sum k 1 5 {expr {pow($k, 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
| using (WebClient webClient = new WebClient()) | |
| { | |
| webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); | |
| byte[] request = System.Text.Encoding.UTF8.GetBytes("payload=" + JsonConvert.SerializeObject(message)); | |
| byte[] response = webClient.UploadData(this._webHookUri, "POST", request); | |
| } |
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.Char | |
| import Control.Monad | |
| import Control.Applicative | |
| para :: (a -> b -> [a] -> b) -> b -> [a] -> b | |
| para f e [] = e | |
| para f e (x:xs) = para f (f x e xs) xs | |
| main = do |
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 ghciEscape arg = "'" ++ concatMap (\c -> if c == '\'' then "'\"'\"'" else [c]) arg ++ "'" | |
| :def! hoogle return . (":! hoogle --color --count=20 " ++) . ghciEscape | |
| :def! doc return . (":! hoogle --color --info " ++) . ghciEscape | |
| :set prompt "\ESC[1;34m%s\n\ESC[0;34mλ> \ESC[m" |
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
| ## Ignore Visual Studio temporary files, build results, and | |
| ## files generated by popular Visual Studio add-ons. | |
| # User-specific files | |
| *.suo | |
| *.user | |
| *.sln.docstates | |
| # Build results | |
| [Dd]ebug/ |
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
| {-# LANGUAGE TupleSections #-} | |
| import Data.Char | |
| import Control.Monad | |
| import Control.Applicative hiding (many) | |
| import Text.ParserCombinators.ReadP | |
| import Test.QuickCheck | |
| data Exp = Add Exp Exp | |
| | Sub Exp Exp |
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
| $.ajax({ url: "foo.csv", dataType: "text" }) | |
| .done(function(data) { | |
| fetchPostTags(data); | |
| $.ajax({ url: "bar.csv", dataType: "text" }) | |
| .done(fetchPostsComments); | |
| .fail(function(failure) { | |
| updateStatus("Failed to load posts-comments.csv"); | |
| console.log(failure); | |
| }); |
NewerOlder