# Need help with syntax

**URL:** <https://forum.canton.network/t/need-help-with-syntax/606>\
**Category:** App Development\
**Tags:** daml\
**Created:** [June 5, 2020, 10:16am UTC](https://forum.canton.network/t/need-help-with-syntax/606 "2020-06-05T10:16:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![axnblue](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@axnblue](https://forum.canton.network/u/axnblue)\
**Post date:** [June 5, 2020, 10:16am UTC](https://forum.canton.network/t/need-help-with-syntax/606/1 "2020-06-05T10:16:42Z")

</div>

Hey everyone, need little help to make a recursive function with pattern matching. So question is like:-  
Suppose a function takes to input (Integer and List[Integer]) and gives back an integer  
So let input be :- [1,2,3, **4** ,5,6] and 4  
And the desired output is [1,2,3]  
2.)  
Input:- [42,32,77,46,34,56] and 46  
Output :- [42,32,77]

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [June 5, 2020, 11:17am UTC](https://forum.canton.network/t/need-help-with-syntax/606/2 "2020-06-05T11:17:54Z")

</div>

I believe you want to use `takeWhile`, which is documented [here](https://docs.daml.com/daml/stdlib/Prelude.html#function-da-internal-prelude-takewhile-72061).

A couple of examples matching the ones you made:

```
takeWhile (/= 4) [1, 2, 3, 4, 5, 6]
takeWhile (/= 46) [42, 32, 77, 46, 34, 56]

```

A convenient way to look for functions in the DAML standard librarys is using Hoogle at [daml.com](http://daml.com), where you can look for functions by their signature, as in [this case](https://hoogle.haskell.org/?hoogle=(a%20-%3E%20Bool)%20-%3E%20%5Ba%5D%20-%3E%20%5Ba%5D) in which I looked for a function with the signature `(a -> Boolean) -> [a] -> [a]`.

---

<div class="post-metadata">

**Author:** ![bernhard](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bernhard/32/356_2.png) [@bernhard](https://forum.canton.network/u/bernhard)\
**Post date:** [June 5, 2020, 12:57pm UTC](https://forum.canton.network/t/need-help-with-syntax/606/3 "2020-06-05T12:57:21Z")

</div>

If you want a function that returns the initial segment up to, but excluding that element, you can make @stefanobaghino-da’s construction generic and define:

```haskell
takeUntil x = takeWhile (/= x)

```
