Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have seen discussions of unwanted nulls in the output in the context of building lists with conditions on the elements, but that is not involved here. I would like to know where the nulls come from and how to avoid generating them.

Clear["Global`*"]

localGroup =
  AstronomicalData["LocalGroup"];

properties = {
   "AlphanumericName",
   "StandardName",
   "AlternateStandardNames",
   "NGCNumber",
   "ApparentMagnitude",
   "Constellation",
   "Declination",
   "RightAscension",
   "DistanceLightYears",
   "GalaxyType",
   "HubbleType",
   "RadialVelocity",
   "Redshift"
   };

lgTable = {#, Table[
      {
       properties[[n]],
       AstronomicalData[#, properties[[n]]]
       },
      {n, 1, Length[properties]}
      ]
     } & /@ localGroup;


displayTable[record_] := Module[{},
  Print[
     #[[1]] <> ": ", #[[2]]
     ] & /@ record[[2]];
  Print["\n"]
  ]

(* display two records for illustration *)

displayTable[#] & /@ lgTable[[1 ;; 2]]
share|improve this question
add comment

closed as too localized by Oleksandr R., m_goldberg, Yves Klett, Ajasja, acl Feb 18 '13 at 11:18

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 5 down vote accepted

Look at Scan and Map in the documentation, Scan[Print, {1, 2, 3}] returns nothing while Map[Print,{1,2,3}] returns three Null

Just change the last line to:

Scan[displayTable, lgTable[[1 ;; 2]]]
share|improve this answer
    
A nice bit of magic. Scan has somehow entirely escaped my notice. I am still hoping to find out what generates the nulls. –  Gary Palmer Feb 18 '13 at 1:15
    
@GaryPalmer Print is returning Null try x=Print["hello"] you'll see FullForm[x] is Null. Or simply FullForm@Print@1 –  ssch Feb 18 '13 at 1:29
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.