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
dpyNullary[ex_] := | |
Grid[{{ex, ""}}, | |
Frame -> {All,False}, | |
Alignment -> Left, | |
Background -> {{LightOrange,{LightYellow}}}]; | |
dpyMultiary[key_, vals_] := | |
With[{c = Length @ vals}, | |
Module[{ | |
spans = Table["", {c}], |
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
ClearAll[generateWithTime, createObserver, observer, observable, | |
disposable, task]; | |
generateWithTime[ | |
initialState_, | |
condition_, | |
resultSelector_, | |
timeSelector_, | |
iterate_] := | |
Module[{ | |
state = initialState, |
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
ClearAll[generateWithTime]; | |
generateWithTime[ | |
initialState_, | |
condition_, | |
resultSelector_, | |
timeSelector_, | |
iterate_] := | |
Module[{ | |
state = initialState, | |
lastTaskForCleanup, |
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
(* | |
Cold GenerateWithTime | |
Rx.Observable.GenerateWithTime = function( | |
initialState, // : State | |
condition, // : State -> bool | |
resultSelector, // : State -> Result | |
timeSelector, // : State -> int | |
iterate) // : State -> State |
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
SetAttributes[captive2, HoldAllComplete]; | |
captive2[expr_ /; NumberQ @ Unevaluated @ expr] := number2[ToString[expr]] | |
captive2[expr_ /; (Head @ Unevaluated @ expr === Symbol)] := symbol2[ToString @ Unevaluated @ expr] | |
captive2[expr_ /; (Head @ Unevaluated @ expr === String)] := string2["\"" <> expr <> "\""] | |
captive2[head_[args___]] := {captive2 @ head, captive2 /@ Unevaluated @ {args}} | |
captive2[x___] := Throw @ {x}; |
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
SetAttributes[gridCaptive2, HoldAllComplete]; | |
dpyCaptive2[{ex_, {}}] := dpyNullary[dpyCaptive2 @ ex]; | |
dpyCaptive2[{a_, {as__}}] := dpyMultiary[dpyCaptive2 @ a, dpyCaptive2 /@ {as}]; | |
dpyCaptive2[number2[ex_]] := dpyQuotedAtom[number2[ex]]; | |
dpyCaptive2[string2[ex_]] := dpyQuotedAtom[string2[ex]]; | |
dpyCaptive2[symbol2[ex_]] := dpyQuotedAtom[symbol2[ex]]; | |
dpyCaptive2[x___] := Throw[Unevaluated @ {x}]; | |
gridCaptive2[expr_] := dpyCaptive2 @ captive2 @ expr; |
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
ClearAll[P, Wff, Proposition, Unary, Binary, T, | |
nonTerminalsFromGrammar, terminalsFromGrammar]; | |
P[Wff] = {{Proposition}, {Unary}, {Binary}}; | |
P[Proposition] = {{"p"}, {"q"}, {"r"}, {"s"}}; | |
P[Unary] = {{"N", Wff}}; | |
P[Binary] = {{"C", Wff, Wff}, {"A", Wff, Wff}, {"K", Wff, Wff}, {"E", | |
Wff, Wff}}; | |
P[Start] = P[Wff]; | |
ClearAll[nonTerminalsFromGrammar]; |
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
gridRules[rules_] /; | |
(ListQ[rules] && | |
(Length @ rules > 0) && | |
(And @@ (((Head @ # === Rule)||(Head @ # === RuleDelayed))& /@ rules))) := | |
With[{ | |
keys = #[[1]]& /@ rules, | |
heads = #[[0]]& /@ rules, | |
vals = gridRules[#[[2]]]& /@ rules}, | |
Grid[MapThread[{ | |
Style[#1, Bold], |
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
(* This code is released into the public domain by its author, Brian \ | |
Beckman, on 2 Aug 2012. *) | |
ClearAll[grid, fopts]; | |
ClearAll[allAreRulesQ, noneAreAtomsQ]; | |
(* A "HoldAll" version of the following, with "Unevaluated" \ | |
everywhere, may be required. *) | |
noneAreAtomsQ[candidates_List] := | |
And @@ (Not[AtomQ@#] & /@ candidates); | |
allAreRulesQ[candidates_List] := |
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
Rx LINQ Operator Precis | |
Brian Beckman, May 2013 | |
================================================================================ | |
Introduction | |
================================================================================ | |
This is a highly abbreviated "cheat-sheet" for the LINQ operators over Rx, the | |
Reactive Extensions. Its purpose is to TEACH by laying bare the regular and | |
tasteful structure of the API. This structure can be difficult to perceive from | |
ordinary documentation and source code because comparable and contrastable |
OlderNewer