Hot answers tagged

3

This is essentially the same algorithm as Leonid's but implemented in terms of Pick instead of sparse arrays: negativePositions2[lst_] := Module[{a, b}, a = Pick[Range[Length[lst]], UnitStep[lst], 0]; b = UnitStep[Differences[a]~Subtract~2]; Transpose[{Pick[a, b~Prepend~1, 1], Pick[a, b~Append~1, 1]}]]


3

Leonid's answer is as impressive as it is too advanced for me (a lot). For lesser mortals like me, not as fast but still acceptable performance: largeTest = RandomInteger[{-100,100},1000000]; a quarter of a second performance for a million length list: Transpose[{#, Append[Rest[# - 1], Length@#]}] & [FoldList[Plus, 1, Length /@ ...


1

Perhaps, ClearAll[inpField] inpField[arg_, fs_: 5] := InputField[arg, FieldSize -> fs, Background -> Yellow, Appearance -> "Frameless"] Interpretation[{f = {-y, -2 x}, xmin = 0, xmax = 1, ymin = 0, ymax = 1}, Panel@Row[{"StreamPlot[", inpField[Dynamic[f], 12], ", \n ", Invisible["StreamPlo"], "{x, ", inpField[Dynamic[xmin]], ",", ...



Only top voted, non community-wiki answers of a minimum length are eligible