Tag Info

New answers tagged

3

Why not just this? f[l_] := Block[{a,b,c}, a = Length[l]; b = First[l]; c = b/a; c*10] Then f[{2, 3, 4, 5}] 5


6

If you have Version 10 use the function Where in the GeneralUtilities package like this: Needs["GeneralUtilities`"] f[l_] := Where[a = Length[l], b = First[l], c = b/a, c*10] Then: f[{2, 3, 4, 5}] 5


5

Taking the question at face value, I think the answer is yes. A While loop While[test, body] evaluates test then body until test fails to give True. This can be implemented in NestWhile by putting test and body into Functions: NestWhile[body &, Null, test &] For example the following both do the same thing: i = 0; While[i < 10, i++]; i = 0; ...



Top 50 recent answers are included