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[symbolRules]; | |
symbolRules[syms_List]:= | |
Join @@ Map[ | |
Function[s, symbolRules @ Unevaluated @ s, HoldFirst], | |
Unevaluated @ syms | |
] | |
symbolRules[sym_String]:= | |
ToExpression[sym, InputForm, Function[s,symbolRules @ Unevaluated @ s, HoldFirst]]; | |
symbolRules[s_Symbol]:= Join[OwnValues[s],DownValues[s], UpValues[s], SubValues[s]]; | |
symbolRules[]:= symbolRules @ Names["Global`*"]; |
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
BeginPackage["OO`"] | |
new | |
EndPackage[] | |
BeginPackage["OO`Core`", "RuleBasedFunction`"] | |
TypeQ; | |
ObjectQ; |
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
BeginPackage["RuleBasedFunction`"] | |
RuleBasedFunction::usage = "RuleBasedFunction[defs, attrs] constructs a pure function based on definitions given by rules"; | |
Fn::usage = "Fn is a symbol used to denote a function in definitions used in RuleBasedFunction"; | |
Begin["`Private`"] | |
SetAttributes[CleanUp, HoldAll] | |
CleanUp[expr_, cleanup_] := |
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
BeginPackage["FrozenCode`"] | |
FrozenCodeEvaluate::usage = "FrozenCodeEvaluate[Hold[code], {heads}] evaluates the code | |
in the 'frozen' mode, where only specific heads are allowed to evaluate"; | |
Begin["`Private`"] | |
ClearAll[symbolToHideQ] | |
SetAttributes[symbolToHideQ, HoldFirst]; | |
symbolToHideQ[s_Symbol, expandedSymbs_] :=! MemberQ[expandedSymbs, Unevaluated[s]]; |
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[Let, let, symbolOrListQ, inSetDelayed]; | |
SetAttributes[{Let, let, symbolOrListQ}, HoldAll]; | |
symbolOrListQ[_Symbol] = True; | |
symbolOrListQ[{___?symbolOrListQ}] = True; | |
symbolOrListQ[_] = False; | |
Let::lvset = "Local variable specification `1` is not valid."; |
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
BeginPackage["ReferenceTracker`"] | |
TrackReferences; | |
Begin["`Private`"] | |
Clear[$globalProperties]; | |
$globalProperties = { | |
OwnValues, | |
DownValues, |
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[shead]; | |
SetAttributes[shead, HoldAllComplete]; | |
shead[f_Symbol[___]] := HoldComplete[f]; | |
shead[f_[___]] := shead[f]; | |
shead[f_ /; AtomQ[Unevaluated[f]]] := Head[f]; | |
(* TODO:This is a bit too simplisitc,since some pattern symbols might \ | |
be localized by inner rules inside expr,and should not be \ | |
counted.We might miss some extra dependencies this way *) |
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
BeginPackage["HTMLParser`"] | |
ParseHTML::usage = "ParseHTML[s] parses a string of HTML code"; | |
HTMLContainer::usage = "HTMLContainer[tag] is an inert container for the contents of html tag"; | |
Begin["`Private`"] | |
listSplit[x_List,lengthlist_List,headlist_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
(* Mathematica Package *) | |
(* :Title: SEFormatter *) | |
(* :Author: Leonid B. Shifrin *) | |
(* :Summary: Code formatting palette for mathematica.stackexchange.com | |
(but can be useful also for other formatting purposes) *) | |
(* :Context: SEFormatter` *) |
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
# include <stdio.h> | |
# include <stdlib.h> | |
# include <time.h> | |
int random_in_range (unsigned int min, unsigned int max) | |
{ | |
int range = max - min, | |
remainder = RAND_MAX % range, | |
bucket = RAND_MAX / range; |