0

I have a function that takes 4-tuple of type list, in the function I need to refer to the input of the function to do some other stuff such as taking the first element of that tuple or get length of the first element of the 4-tuple my function takes as following

foo (a:_,b:_,c:_,d:_) = do something 

in the do some thing part i need to do some comparisons but I need the refer to the input of foo and I don't know how . I went like this

let input = (a:_,b:_,c:_,d:_) in foo input // generates error

Can anyone help me out?

1 Answer 1

4

You can write

foo args@(a:_,b:_,c:_,d:_) = if bar args then (a,c) else (b,d)

In the second case you get an error because wildcards cannot appear on the right side of binding expression

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

2 Comments

I used it like this but not working zed args@(a:_,b:_,c:_,d:_) = if ( length ( get1th ( bar args ) ) == 2 ) then get1th ( bar args ) else get1th ( bar args)
Please show your code. I suppose you have a type error since this is syntactically correct

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.