Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. If[Length[$ScriptCommandLine]==1,
  2. Print["No expressions were given to square."],
  3.  
  4. args = Rest[$ScriptCommandLine];
  5. squares = Quiet @ Map[Replace[ToExpression[#], {$Failed:>ToString[#,InputForm]^2, x_ :> x^2}]&, args];
  6. MapThread[Print["The square of ", #1, " is ", #2, "."]&, {args, squares}]
  7. ]
  8.  
  9. "If[Length[$ScriptCommandLine]==1,
  10. Print["No expressions were given to square."],
  11.  
  12. args = Rest[$ScriptCommandLine];
  13. squares = Quiet @ Map[Replace[ToExpression[#], {$Failed:>ToString[#,InputForm]^2, x_ :> x^2}]&, args];
  14. MapThread[Print["The square of ", #1, " is ", #2, "."]&, {args, squares}]
  15. ]".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement