Pensieve header: September 29: Textbook (EIWL) chapters 5-8, evaluated.

5. Operations on Lists

{1,2,3}+10

{1,2,3}/10

?List

??List

?Plus

??Plus

?Flat

f[1,f[2,3]]

SetAttributes[f, Flat]

f[1,f[2,3]]

?Listable

f[1,{2,3,4}]

SetAttributes[f, Listable]

f[1,{2,3,4}]

{1,1,2}*{1,2,3}

f[{a,b},{x,y}]

Range[10]^2

Sort[{4,2,1,3,6}]

?SortBy

?RandomReal

l=RandomReal[{-1,1},10]

Sort[l]

SortBy[l,Abs]

Length[{5,3,4,5,3,4,5}]

Dimensions[{{1,2,3},{4,5,6}}]

Total[{1,1,2,2}]

Total[Range[10]]

Count[{a,b,a,a,c,b,a},a]

?Count

?Pattern

Count[{a,b,a,a,c,b,a},_^_]

Expand[(((a+b))^10)]

List@@Expand[(((a+b))^10)]

Count[List@@Expand[(((a+b))^10)], _^_]

Count[List@@Expand[(((a+b))^10)], _*(_^_)]

Count[List@@Expand[(((a+b))^10)], __*(_^_)]

g1[x_] := x^2

g1[2]

g1[2,3]

g2[x__]:={x}

g2[2]

g2[2,3]

g3[x___]:={x}

g3[]

First[{7,6,5}]

Last[{7,6,5}]

Part[{7,6,5}, 2]

First[Sort[{6,7,1,2,4,5}]]

Min[{6,7,1,2,4,5}]

IntegerDigits[1988]

Last[IntegerDigits[1988]]

Take[{101,203,401,602,332,412},3]

Take[IntegerDigits[2^100],10]

Drop[{101,203,401,602,332,412},3]

6. Making Tables

Table[5,10]

Table[x,10]

Table[{1,2},10]

Table[{1,2},10] // Dimensions

Table[{1,2},10,3] // Dimensions

Table[PieChart[{1,1,1}],3]

Table[a[n],{n,5}]

Table[n+1,{n,10}]

Table[n^2,{n,10}]

tab=Table[n+((Range[n])^2),{n,5}]

tab[[5,2]]

tab[[2,5]]

tab[[All, 1]]

tab[[3,All]]

tab[[3]]

tab[[All,2]]

tab[[2;;, 2]]

tab// Length

tab//Dimensions

Table[Column[Range[n]],{n,8}]

Table[ListPlot[Range[10*n]],{n,3}]

Table[PieChart[Table[1,n]],{n,5}]

Table[2^expt,{expt,10}]

Table[{x,x+1,x^2},{x,5}]

Table[f[n],{n,10}]

Table[f[n],{n,4,10}]

Table[f[n],{n,4,10,2}]

Range[4,10]

Range[4,10,2]

f/@Range[4,10,2]

Range[0,1,0.1]

ListPlot[Table[x-x^2,{x,0,1,.02}]]

ListPlot[Range[0,1,.02]-Range[0,1,.02]^2]

Table[RandomInteger[10],20]

RandomInteger[10,20]

7. Colors and Styles

Red

{Red,Green,Blue,Purple,Orange,Black}

ColorNegate[Yellow]

Blend[{Yellow,Pink,Green}]

RGBColor[1,0,0]

RGBColor[1,1,0]

Table[RGBColor[1,g,0],{g,0,1,0.05}]

Hue[0.5]

Table[Hue[u],{u,0,1,0.05}]

RandomColor[]

Table[RandomColor[],30]

Blend[Table[RandomColor[],20]]

Style[1000,Red]

Table[Style[RandomInteger[1000],RandomColor[]],30]

Style[x,30]

Table[Style[100,n],{n,30}]

Table[Style[x,RandomColor[],RandomInteger[30]],25]

8. Basic Graphics Objects

Graphics[Circle[]]

?Circle

Graphics[Circle[{1,2},4]]

Graphics[Table[Circle[{RandomReal[],RandomReal[]}, RandomReal[]], 10]]

Graphics[{Disk[{0,0},0.1],
Table[
{RandomColor[],Circle[{RandomReal[],RandomReal[]}, RandomReal[]]},
 10]
}]

Graphics[Disk[]]

Graphics[RegularPolygon[5]]

Table[Graphics[RegularPolygon[n]],{n,5,10}]

?Line

?Arrow

?Polygon

Graphics[{Orange,RegularPolygon[5]}]

Graphics3D[Sphere[]]

{Graphics3D[Cone[]],Graphics3D[Cylinder[]]}

Graphics3D[{Cone[], Opacity[0.5],Cylinder[]}]

Graphics3D[{Yellow, Sphere[]}]

Graphics3D[Style[Sphere[],Yellow]]

?Tuples

Tuples[{1,-1},3]

Graphics3D[{
Yellow, Opacity[0.5], Table[Sphere[c,1], {c, Tuples[{1,-1},3]}],
Blue, Opacity[1],Sphere[{0,0,0}, Sqrt[3]-1]
}]