Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

16
  • 1
    $\begingroup$ -1, this doesn't answer the question. The solution would be fine if instead of AnyTrue you had nthTrue, but nthTrue is not a built-in. $\endgroup$ Commented May 4, 2017 at 9:50
  • $\begingroup$ Fair enough. I optimised it base on Marius's method. $\endgroup$ Commented May 4, 2017 at 12:49
  • $\begingroup$ un-downvoted, but this is essentially identical to the accepted answer + some very odd memoization technique, which I'm not sure what is achieving here. You know, your original approach would have easily been doable as Select[data, #[[n]] != 0 &]. As an aside, I see you using memoization in many of your recent answers, why do you utilize it so heavily? $\endgroup$ Commented May 4, 2017 at 13:57
  • 1
    $\begingroup$ In Functional Programming, we call it Pure Function, It's NOT Pure Function in Wolfram Language. Pure Functions in Wolfram Language is just anonymous functions. When I know that a function has no side effect, such as File System, Network, I implement it as a Pure Function(Functional Programming term). $\endgroup$ Commented May 4, 2017 at 14:08
  • $\begingroup$ The pure function always evaluates the same result value given the same argument value(s). The function result value cannot depend on any hidden information or state that may change while program execution proceeds or between different executions of the program, nor can it depend on any external input from I/O devices (usually—see below). Evaluation of the result does not cause any semantically observable side effect or output, such as mutation of mutable objects or output to I/O devices. en.wikipedia.org/wiki/Pure_function $\endgroup$ Commented May 4, 2017 at 14:08