-
Install Putty
-
Connect to server over ssh
-
Login with username then password
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 System; | |
using System.Linq; | |
using System.Collections.Generic; | |
namespace DearCSharpYouLose { | |
public static class FuncExtension { | |
public static Func<A, C> Select<A, B, C>(this Func<A, B> f, Func<B, C> g) { | |
return a => g(f(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
//How can we do this imperitive process with Haskell/Purescript style functions? | |
//Examples | |
// > generateQuestions([1,2,3,4,5,6,7,8])(3)(2) | |
// [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] | |
// > generateQuestions([1,2,3,4,5])(2)(4) | |
// [ [ 1, 2 ], [ 3, 4 ], [ 5, 1 ], [ 2, 3 ] ] |
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.Array | |
import Data.Array.ST (empty, push, freeze) | |
import Data.Either (Either(..)) | |
import Control.Monad.ST.Internal (ST, foreach) | |
-- Return Rights from an Array of Either's using the ST monad | |
rights :: forall a b. Array (Either a b) -> Array b | |
rights array = | |
let | |
-- This seems to be required because |
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.Either (Either(..), either, hush) | |
import Data.Array (mapMaybe) | |
import Data.Maybe (Maybe(..)) | |
rights :: forall a b. Array (Either a b) -> Array b | |
rights array = mapMaybe hush array | |
-- Also the Lefts implementation | |
lefts :: forall a b. Array (Either a b) -> Array a | |
lefts array = mapMaybe (either Just (const Nothing)) array |
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.Array (snoc) | |
import Data.Either (Either(..)) | |
rights :: forall a b. Array (Either a b) -> Array b | |
rights array = | |
let | |
f (Left _) accumulator = accumulator | |
f (Right value) accumulator = snoc accumulator value | |
in | |
foldr f [] array |
NOTE: This is an article by Chris Taylor, originally posted on his blog, but the blog was removed at some point. I resurected it from the WayBack Machine without the authors permission, but post it here for posterity's sake, so others may be able to find it.
by Chris Taylor
FEB 10TH, 2013
Thanks to @user#0540 and @Globi#0117 on the #beginners discord
Question:
Coming from JS/C#/Haskell and trying to understand the &
and *
a bit better. In this code snippet, the n
in the lambda apparently can either be |&n| n%2==0
or |n| *n%2==0
. Could some one explain this a bit better? I think its something to do with reference/defreferece, but still not comfortable with those ideas.
let arr: [u16; 5] = [1, 2, 3, 4, 5];
let mut iterator = arr.iter().filter(|&n| n%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
interface Integer2Integer { | |
int apply(int n); | |
} | |
static int blah(Integer2Integer r) { return r.apply(99); } | |
class Plus10 : Integer2Integer { Integer2Integer { int apply(int n) { return n + 10; } } | |
Console.WriteLine(blah(new Plus())); // what does that print? | |
maybe even a type alias | |
type Integer2Integer = Int -> Int | |
blah r = r 99 |
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 Lib | |
( someFunc | |
) where | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
import Hedgehog | |
import qualified Hedgehog.Gen as Gen | |
import qualified Hedgehog.Range as Range |