| Original Message (ID '272359') By yehuda: |
| Try to use internal functions as much as possible. The key function here is Split, all the rest is "cosmetics"
l = {1, 2, 5, 9, 4, 2, 1, 10, 12, 1};
ups = Length@Select[Split[l, #1 < #2 &], Length[#] > 1 &]
downs = Length@Select[Split[l, #1 > #2 &], Length[#] > 1 &]
or similarly, using Count
ups=Count[Split[l, #1 < #2 &], x_ /; Length[x] > 1]
downs=Count[Split[l, #1 > #2 &], x_ /; Length[x] > 1]
yehuda |
|