-
Notifications
You must be signed in to change notification settings - Fork 0
/
thingsToTry
27 lines (16 loc) · 2.57 KB
/
thingsToTry
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
sPrime = If[# <= 1, False, If[# <= 2, True, If[#/2 - Floor[#/2] <= 0, False, p=True; n=Floor[Sqrt[#]]; n=n+Boole[n/2 - Floor[n/2] <= 0]; While[n >= 3 && p, p = (#/n - Floor[#/n] > 0); n=n-2]; p]]] &;
fibseq = If[# <= 0, {}, If[# <= 1, {1}, If[# <= 2, {1,1}, seq={1,1}; n=2; While[n < #, seq = Append[seq, seq[[-1]] + seq[[-2]]]; n = n+1];seq]]]&
If[Equal[Slot, List], If[Equal[Length[Slot[1]], 0], {}, CompoundExpression[Set[pre, Part[Slot[1], 1]], Set[k, 1], Set[result, {}], Set[n, 2], While[LessEqual[n, Length[Slot[1]]], CompoundExpression[If[TrueQ[Equal[Part[Slot[1], n], pre]], Set[k, k+1], CompoundExpression[Set[result, Append[Append[result, {k}], pre]], Set[pre, Part[Slot[1], n]], Set[k, 1], Null]], Set[n, n+1]]], Set[result, Append[Append[result, {k}], pre]], result]], error]
sierpinski := If[ #7 == 0, Polygon[{{#1,#2},{#3,#4},{#5,#6}}],{#0[#1, #2, (#1+#3)/2, (#2+#4)/2, (#1+#5)/2, (#2+#6)/2, #7 - 1],#0[(#1+#3)/2, (#2+#4)/2, #3, #4, (#3+#5)/2, (#4+#6)/2, #7 - 1],#0[(#1+#5)/2, (#2+#6)/2, (#3+#5)/2, (#4+#6)/2, #5, #6, #7 - 1]}]&; Graphics[sierpinski[-1,0,1,0,0,1,5]]
resolution = 0.1; iterationCount = 10; mandelbrot = (c = #; z = 0; n = 0; inside = True; While[n < iterationCount && inside, inside = (Re[z]^2 + Im[z]^2 < 4); z = c + z*z; n = n + 1]; n) &; Graphics[Table[{iter = mandelbrot[Complex[x, y]]; If[iter == iterationCount, White, RGBColor[1 - iter/iterationCount, 1 - iter/iterationCount, iter/iterationCount]], Rectangle[{x-resolution/2, y-resolution/2}, {x+resolution/2, y+resolution/2}]}, {x, -2.5, 1, resolution}, {y, -1, 1, resolution}]]
toCFN = Block[{go = If[ Floor[#] - # == 0, {#}, If[ #2 == 0, {}, Prepend[go[ 1/(#-Floor[#]), #2-1], Floor[#] ]] ]&, res = go[#, #2]}, res - Table[ If[i == Length[res], 1, 0] , {i, Length[res]} ]]& ;
fromCF = Block[{go = If[ Length[#1] == #2, #1[[#2]] + 1, #1[[#2]] + 1/go[#1, #2+1] ]&}, go[#, 1] ]&;
toCF = Block[{go = If[ Floor[#] - # == 0, {#}, Prepend[go[ 1/(#-Floor[#])], Floor[#] ] ]&, res = go[#]}, res - Table[ If[i == Length[res], 1, 0] , {i, Length[res]} ]]& ;
toEE = Block[{go = If[# == 0, {}, Prepend[go[# * Ceiling[1/#] - 1], Ceiling[1/#]]] &}, go[#]]&;
fromEE = Block[{go = If[ Length[#1] == #2, 1/#1[[#2]], (1 + go[#1, #2+1])/#1[[#2]] ]&}, go[#, 1] ]&;
polarPlot = Graphics[Line[Table[ #1 * { Cos[#2[[1]]], Sin[#2[[1]]] }, #2]]]&; polarPlot[1/x, {x, 1, 10Pi, 0.1}]
t=N[2Pi]/(2.0*RandomReal[]-1)+N[Pi/2];
l=Append[Table[Text[i, {Sin[2i*Pi/12], Cos[2i*Pi/12]}], {i, 1, 12}], Circle[{0.1,0.1},1.5]];
l=Append[l, Arrow[{{0.1, 0.1},{0.5*Cos[t], 0.5*Sin[t]}}]];
l=Append[l, Arrow[{{0.1, 0.1},{Cos[60*t], Sin[60*t]}}]];
Graphics[l]