Search code examples
lambdafunctional-programmingplaceholderelm

Is there any equivalent of placeholder in Elm?


Is it possible to write the function in the following way:

find_parts: String -> List String -> List String                                                                        
find_parts word parts =
  List.filter String.contains _ word parts

Instead of:

find_parts: String -> List String -> List String
find_parts word parts =
  List.filter (\part -> String.contains part word) parts 

Solution

  • If there is, it is not documented.

    Alternative solution, if you just want to avoid the lambda syntax use the now-deprecated flip if you're using something earlier than 0.19:

    find_parts: String -> List String -> List String
    find_parts word parts =
      List.filter (flip String.contains word) parts