WolframLang: FullForm vs Short Syntax Example

By Xah Lee. Date: .

This page shows real life code example of FullForm Syntax vs short syntax.

Example 1

Short syntax:

cArray = CoordinateBoundsArray[{{-1, 1}, {-1, 1}}, Into[4]];
hLines = (BlockMap[Line, #1, 2, 1] & ) /@ cArray

FullForm syntax:

CompoundExpression[

 Set[ cArray,
  CoordinateBoundsArray[
   List[List[-1, 1], List[-1, 1]],
   Into[4]
  ]
 ],

 Set[
  hLines,
  Map[
   Function[
    BlockMap[Line, Slot[1], 2, 1]
   ],
   cArray
  ]
 ]
]

Example 2

short syntax:

geoInv = ((With[{x662 = #.#}, If[ x662 < 0.00000001, #, #/x662] ]) &);

 gridDivN = 16;
 nGon = 4;
 rr = (2/gridDivN)/2 (Sqrt@2) .7;
 \[Alpha] = 2 Pi/8;

 gridPoints =
  Map[geoInv,
   CoordinateBoundsArray[{{-1, 1}, {-1, 1}}, Into@gridDivN], {2}];

 gp1 = With[{sq = ((({Cos[#], Sin[#]} rr) &) /@
       Range[\[Alpha], 2 \[Pi] + \[Alpha] - 2 \[Pi]/nGon/2,
        2 \[Pi]/nGon])},
   Map[Function[{x},
     GraphicsComplex[((x + #) &) /@ (sq x . x),
      Line@Append[Range@nGon, 1]]], gridPoints, {2}]];

 gp2 = gp1 /.
   GraphicsComplex[x_, r__] :> GraphicsComplex[geoInv /@ x, r];

 gr1 = Graphics[gp1, Axes -> True];
 gr2 = Graphics[gp2, Axes -> True];

 GraphicsGrid[{{gr1, gr2}}]

FullForm syntax:

CompoundExpression[
 Set[geoInv,
  Function[With[List[Set[x662, Dot[Slot[1], Slot[1]]]],
    If[Less[x662, 1.`*^-8], Slot[1], Times[Slot[1], Power[x662, -1]]]]]],
 Set[gridDivN, 16], Set[nGon, 4],
 Set[rr, Times[Times[Times[2, Power[gridDivN, -1]], Power[2, -1]],
   Sqrt[2], 0.7`]], Set[\[Alpha], Times[2, Times[Pi, Power[8, -1]]]],
 Set[gridPoints,
  Map[geoInv,
   CoordinateBoundsArray[List[List[-1, 1], List[-1, 1]],
    Into[gridDivN]], List[2]]],
 Set[gp1, With[
   List[Set[sq,
     Map[Function[Times[List[Cos[Slot[1]], Sin[Slot[1]]], rr]],
      Range[\[Alpha],
       Plus[Times[2, Pi], \[Alpha],
        Times[-1,
         Times[2, Times[Times[Pi, Power[nGon, -1]], Power[2, -1]]]]],
       Times[2, Times[Pi, Power[nGon, -1]]]]]]],
   Map[Function[List[x],
     GraphicsComplex[
      Map[Function[Plus[x, Slot[1]]], Times[sq, Dot[x, x]]],
      Line[Append[Range[nGon], 1]]]], gridPoints, List[2]]]],
 Set[gp2, ReplaceAll[gp1,
   RuleDelayed[
    GraphicsComplex[Pattern[x, Blank[]], Pattern[r, BlankSequence[]]],
     GraphicsComplex[Map[geoInv, x], r]]]],
 Set[gr1, Graphics[gp1, Rule[Axes, True]]],
 Set[gr2, Graphics[gp2, Rule[Axes, True]]],
 GraphicsGrid[List[List[gr1, gr2]]]]

WolframLang Syntax