0
40 Revit2009crackxforce32

Revit2009crackxforce32. 01/12/2013 18:07. Brasil.Q:

How to find a specific unknown value in a list of unknown values?

Suppose I have a list of the form:
{{0.5, 1}, {1, 2}, {1.2, 3}, {0.8, 4}}

How can I write a function which returns the value corresponding to the first occurrence of a numerical value? In this case the function should return the value 2.
Also, is there a name for the technique of solving this kind of problem in general?

A:

You can use the FindSequenceFunction to get the value in position x and use SequenceCases to get the result:
res = SequenceCases[{0.5, 1, 1.2, 0.8}, x_ /; NumericQ[x] :> x]
(* {2, 0, 3, 4} *)

If your list is much longer, it might be faster to do a Full[#] & for non-numerical elements:
res = SequenceCases[
Full[{0.5, 1, 1.2, 0.8, {0.1, 2}, {0.2, 3}, {0.8, 4}]],
x_ /; NumericQ[x] :> x]

or
res = SequenceCases[
Full[{0.5, 1, 1.2, 0.8, {0.1, 2}, {0.2, 3}, {0.8, 4}, {1.,
2}, {1.2, 3.}, {1.2, 4}, {0.8, 4}], #[] /;
NumericQ[#[]] &],
x_ /; NumericQ[x] :> x]

A:

You can do this with a recursive function that stops if it finds the desired value or starts returning the same value for future values:
ClearAll[f]
f[dims_, start_] :=
Function[{d},
Switch[dims,
{d_, n_
37a470d65a