Questions tagged [pointfree]

The pointfree (also called pointless) style of defining a function is to express it directly in terms of existing functions, without mentioning the arguments of the function being defined. Function composition and partial application are often used.

The pointfree (also called pointless) style of defining a function is to express it directly in terms of existing functions (regarded as combinators), without mentioning the arguments of the function being defined. Function composition and partial application are often used.

See also .

292 questions
0
votes
0 answers

Why is the Observable .map operator defined to require a second parameter in its callback?

I have a function, in this case I'm using XLSX.read this function is defined to take one argument, and a second which may be undef (which is what I want). Yet, when I try to use this function pointfree in an Rxjs Observable, like this .pipe( …
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
0
votes
2 answers

Using apply or call to create a pointfree function?

Let's say that I want to create a function that trims its input, one way I can do it is simply x => x.trim() Another way would be x => String.prototype.trim.call(x) Which has the advantage that if x has defined an override for the .trim(), I can…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
0
votes
1 answer

point-free style and partially applied functions

In Haskell there are two concepts that doesn't look like they are the same, but I don't understand the difference. They are "point-free style" and "partially applied functions". For point-free styles I'm going to get this example: instead of: sum xs…
user9640427
0
votes
3 answers

Pointfree-Style with template-string in ramda.js

I've problems writing a pointfree-style function in ramda.js and wondered if anybody can help me with that. The getEnv function reads an env-variable and logs to console if it couldn't be found. Here is my code const env = name => R.path(['env',…
0
votes
1 answer

Point-free pipe range with Ramdajs

I have my function that creates ranges: const range = from => to => step => .... And i want to create another function that do something with that range, but i want to use pipe. For example i want to get the sum of the range. const sum = ... const…
user2693928
0
votes
2 answers

Making something point-free in Ramda

I'm learning about the JS Library Ramda rightnow. And there seems to be a pattern i am unable to resolve properly. For example i have this code. const filterPayments = filter => payments => r.filter( r.allPass([ typePred(filter), …
Mauravan
  • 39
  • 9
0
votes
3 answers

Compose Ramda Functions

Hi am just learning the Ramda library and loving it. I am trying to practice some functional concepts like curry and immutability. Below I have a little code that is basically trying to assoc the value from one object and copy that to another…
nzaleski
  • 433
  • 5
  • 14
0
votes
1 answer

Function composition of form f(x)(g(x)) using Ramda

I can't figure out a transform for f(x)(g(x)) using the functions available in Ramda. I'm hoping for something like R.something(f, g)(x) ideally - just so long as x only appears once and is the final argument. f is a function taking x that returns a…
RichK
  • 11,318
  • 6
  • 35
  • 49
0
votes
1 answer

How to make an if statement point free

I have the following if statement: var formatCity = obj => R.both(has('city'), has('state'))(obj) ? appendCommaToCity(obj) : obj I would like to make this code point free, but can not figure out a way around the if statement.
Sepehr Sobhani
  • 862
  • 3
  • 12
  • 29
0
votes
1 answer

how to write a function using list comprehension in haskell?

I've written this function using map, but I need to write this using list comprehension: alter = map (\x -> if x == 0 then 1 else 0) it gives e.g. alter [1,1,0] > [0,0,1]
USERSFU
  • 69
  • 10
0
votes
2 answers

Is there a way to write this Javascript function without listing the arguments?

I'm trying to write a function that compares two items using another function, then checks if the result is greater than some other value also provided to the function. I can write it like this: const compareDifference = function(t1, t2, threshold)…
0
votes
2 answers

when to use and when not to use pointfree style in haskell?

I just learned about pointfree style in Haskell and how it can help tidy up the code and make it easier to read. But sometimes they can make the code a bit too terse. So, when I should I always use pointfree style and at what scenarios should I…
0
votes
0 answers

Compose function with two arguments

I ran into something that threw me off today. I was trying to define a function equivalent to Data.Text.commonPrefixes that throws away everything but the prefix. The following works: commonPrefix :: Text -> Text -> Maybe Text commonPrefix a b =…
Sean Clark Hess
  • 15,859
  • 12
  • 52
  • 100
0
votes
1 answer

Haskell difference lists and point free function

I was researching difference lists and found the DList type newtype DList a = DL { unDL :: [a] -> [a] } and the function dlToList :: DList a -> [a] dlToList = ($[]) . unDL I am wondering what is the non point free version of the function and what…
G.G
  • 27
  • 4
0
votes
2 answers

pointfree add to list in haskell

I'm trying to derive function of three args, using simple function chaining. The function should be of type addToList :: a -> a -> a -> [a] and be pointfree analogue of addToList :: a b c = (a : (b : (c : []))) So far, I've figured out addToList…
Agnis
  • 25
  • 3
1 2 3
19
20