haskell: recursive function that return the char in a tuple list with certain condition(compare)
<p>I'm learning recursive function in haskell that confused with such conditon:</p>

<p>I got a tuple list here:</p>

<pre><code>[(0.5,'!'),(1,'*'),(1.5,'#')]
</code></pre>

<p>What I want to do is input a number n and compare with fist number in each tuple of the list</p>

<p>so suppose n=0.1, when it compared 0.5 and find it is smaller than 0.5, it will return char '!'</p>

<p>suppose n=0.7, which is > 0.5 and keep comparing, find that it &lt; 1, then it will return char '*'</p>

<p>and after compare the whole list and find d is still bigger than the last one, it will just return char 'n'</p>

<p>I've been work with such condition lots of time,but still cannot get to this, here is my code:</p>

<pre><code>find :: Double -&gt; [(Double,Char)] -&gt; Char
find d [] = ' '
find d xs
    | d &lt;= Double(xs[0]) = xs[0]
    | d &gt; Double(xs[0]) = find d tail(xs)
</code></pre>

<p>please use recursion!</p>

<p><a href="https://en.wikibooks.org/wiki/Haskell/Lists_and_tuples" rel="nofollow">tuple</a> is different from array in Haskell</p>

<pre><code>find :: Double -&gt; [(Double,Char)] -&gt; Char
find d [] = ' '
find d (x:xs)
    | d &lt;= fst x = snd x
    | otherwise = find d xs
</code></pre>

python haskell