0

I have this function

func1 :: Double -> [(Double,Double)] -> Maybe [(Double,Double)]
...............
func2 :: Double -> [(Double,Double)] -> [(Double,Double)]
func2 d [] =  []
func2 d list = 
  let dsegs1 = func1 d list
      dsegs2 = func2 d (tail list)
  in  fromJust dsegs1 ++ dsegs2

The simple flow I would like to achieve in func2 is as follows:

let x = func2 3.0 list
let y = func2 3.0 (tail list)
let z = func2 3.0 (tail (tail list))
let a = func2 3.0 (tail (tail (tail list)))

call func2 n times until it returns nothing at the end and concat x,y,z,..., a.

How would I do that?

1 Answer 1

1

It looks like you want map (func2 3.0) (tails list).

Sign up to request clarification or add additional context in comments.

1 Comment

thanks.. i solved it anyways but has 5 lines of code.. your one is so simple.. thanks man

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.