Category "functional-programming"

Check if one element exists in an array of objects

I have the following array of objects: var memberships = [ { id: 1, type: 'guest' }, { id: 2, type: 'member' } ]; How can I verify if

getStrLn in ZIO working with flatMap but not inside for comprehension

val askNameFlatMap: ZIO[Console, IOException, Unit] = putStrLn("What is your Name? ") *> getStrLn.flatMap(name => putStrLn(s"Hello $name")) val askNa

Apply multiple functions with map

I have 2D data that I want to apply multiple functions to. The actual code uses xlrd and an .xlsx file, but I'll provide the following boiler-plate so the outpu

Java Stream: divide into two lists by boolean predicate

I have a list of employees. They have isActive boolean field. I would like to divide employees into two lists: activeEmployees and formerEmployees. Is it possib

PHP's array_map including keys

Is there a way of doing something like this: $test_array = array("first_key" => "first_value", "second_key" => "second_value"); var

Is it possible to define an infix function?

Is it possible to define my own infix function/operator in CoffeeScript (or in pure JavaScript)? e.g. I want to call a foo b or a `foo` b instead of a.fo

Is implementing the words function possible without a postprocessing step after folding?

Real World Haskell, chapter 4, page 98 of the print asks if words can be implemented using folds, and this is my question too: Is it possible? If not, why? If i

Reverse a list in haskell

I am trying to reverse a list. Following is my code: reverseList :: [Int] -> [Int] reverseList [] = [] reverseList (x:xs) = x:reverseList xs What ends u

python map string split list

I am trying to map the str.split function to an array of string. namely, I would like to split all the strings in a string array that follow the same format. An

object.type does not take parameter error

Following is the code snippet I am using from play with scala book. It works well in the framework but when I try in the commndline it gives the error error:

About using Swiftz library issues(Functional programing)

Recently I'm learning functional programing using swift programing language, and found a library named Swiftz, I found a very strange way to call function and w