This file contains 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 strict"; | |
const AND = 'AND', | |
OR = 'OR'; | |
function parsePoleBools(arr){ | |
/* | |
takes: | |
an array of: | |
bools and/or functions that evaluate to bools | |
tokens representing boolean comparison | |
(all in reverse polish notation order) |
This file contains 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 strict"; | |
const _L = require('lodash'); | |
function combinationOfSetsWithLeastWaste(targetSet,candidateGroup){ | |
/* | |
Finds the group of sets whose intersection equals the target set, while | |
containing the least waste through extraneous or overlapping items. | |
where candidateGroup is a collection of objects as: |
This file contains 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 strict"; | |
function ReactFunctor(tag,attr,props,children){ | |
let classArgs = { | |
render : function render() { | |
return React.createElement(tag,this.props,this.props.children); | |
} | |
}; | |
if (props !== null) Object.assign(classArgs,props); | |
return React.createElement(React.createClass(classArgs),attr,children); |
This file contains 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
var Application = Packages.com.parasoft.api.Application; | |
var WebBrowserUtil = Packages.webking.api.browser2.WebBrowserUtil; | |
//set Target Frame | |
var frameName = 'popupFrame'; | |
//set type of target Element | |
var targetElementType = 'button'; | |
function getFrameDocument(input, context) { | |
//This function lets us get a fake document object to work with. | |
var document = input.getDocument('',frameName); |
This file contains 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
goApp :: App n -> IO n | |
goApp init = evalStateT (runApp init) initAppState | |
scheduleGTKStuff :: IO () -> IO () | |
scheduleGTKStuff action = do | |
void $ Gdk.threadsAddIdle GLib.PRIORITY_DEFAULT $ do | |
action | |
return False |
This file contains 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
/help | |
--programA/ | |
----docs/ | |
------docmarkup.doc | |
------docchoices.choice | |
-------/choiceA | |
-------/choiceB | |
where docmarkup is the text for this step | |
.choice is just a line delimited list of the following: |
This file contains 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
passesPredicate :: (POExpinDoc -> Bool) -> (Either ParseError POExpinDoc -> Bool) | |
passesPredicate p = either (\_ -> True) (p) | |
both :: (a->c) -> (b->c) -> Either a b -> Either c c | |
both fl fr inp = | |
case inp of | |
Left l -> Left (fl $! l) | |
Right r -> Right (fr $! r) | |
This file contains 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
flipT :: (x,y) -> (y,x) | |
flipT (x,y) = (y,x) | |
splitOnes :: (Eq a, Ord a) => [a] -> [([a],[a])] | |
splitOnes xs = map flipT . M.toList . M.fromList . map flipT . map (\n -> partition (==n) xs) $ xs | |
splitTwos :: (Eq a, Ord a) => [a] -> [([a],[a])] | |
splitTwos xs = map flipT . M.toList . M.fromList . concatMap splitAgain . splitOnes $ xs | |
where | |
splitAgain (n,xs) = |
This file contains 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
fizzBuzzing :: [Int] -> IO () -- Function name and type signature. Says : Take an array of Int and return an IO action of (). () is pronounced 'unit', similar to Java's void. | |
fizzBuzzing a = -- function named fizzBuzzing with argument a is defined as... | |
case a of -- given a value a of | |
[] -> return () -- a blank list, do nothing. 'return' casts the value () as an IO (), which is necessary to type-check. | |
(x:xs) -> do -- for a list of the form x : xs, where x is the first item and xs is the rest of the list 'do..' | |
decide x -- do notation allows us to put multiple statements in a row, where the last one is the final result statement of the function. This requires the return type to implement an instance of the Monad typeclass - a more complicated subject. | |
fizzBuzzing xs -- t |
This file contains 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 GeneralizedNewtypeDeriving #-} | |
module Example () where | |
import Control.Monad | |
import Control.Monad.IO.Class | |
import Control.Monad.State.Strict | |
type MyAppState = Int -- Your state implementation here. |
OlderNewer