What is the name of λx.λf.fx (like reverse apply) in lambda calculus? Does the corresponding function have a standard name in programming?

What is the name of λx.λf.fx in lambda calculus?

Does the corresponding function have a standard name in functional programming languages, like Haskell?

In object oriented programming, is there a usual name for a method foo which takes a function as an argument, such that x.foo(f) returns f(x)?

3

In Haskell, x.f.f x is flip ($) which as $ is read as apply, I would read as reverse apply.

Roughly based on https://stackoverflow.com/questions/4090168/is-there-an-inverse-of-the-haskell-operator

3

Using the standard combinators you can express this function as

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>C I
</code>
<code>C I </code>
C I

where

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>C f x y = (f y) x
</code>
<code>C f x y = (f y) x </code>
C f x y = (f y) x

In Haskell it would be

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>flip id
</code>
<code>flip id </code>
flip id

Here id‘s type is specialized to (a -> b) -> a -> b and flip swaps a -> b and a.

You can also express it in the SKI calculus:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>S (K (S I)) K
</code>
<code>S (K (S I)) K </code>
S (K (S I)) K

1

In the original Alonzo Church’s “The calculi of lambda-conversion”, he denotes this combinator by T.

In the context of Church numerals, it is called exp.
This matches the “shorthand” notation used by Church for the “application” of a term N to a term M: “[MN]” stands for “(NM)”.

I haven’t heard yet of a standard name for an analogous function in programming.

This is sometimes referred to as the thrush combinator, and in Clojure it’s called the thread-first macro. It’s primary use is in allowing you to express a computation as a series of chained computations in the order they execute in. For instance, taking a value x, passing it to a function f, then passing the results of f(x) to a function g, would be written as g(f(x)) using standard function composition (or g (f x) if you’re working with implicit parentheses.) This can be awkward when there’s a large number of chained functions because you have to read them in the reverse order of how they execute. The thrush combinator lets you express this differently, if we define the thrush combinator as:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>T x f = f x
T x f g ... = T (T x f) g ...
</code>
<code>T x f = f x T x f g ... = T (T x f) g ... </code>
T x f = f x
T x f g ... = T (T x f) g ...

Then the expression T x f g h becomes h (g (f x)).

(For those looking for more information as well as a concrete implementation in the language Racket, I have a blog post on the subject: Thrush Combinator in Racket)

I hope I understand your question correctly, but I believe this is known as the (reverse) Pipe Operator in ML languages.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>[1; 2; 3] |> List.map sq // let it = [1; 4; 9]
</code>
<code>[1; 2; 3] |> List.map sq // let it = [1; 4; 9] </code>
[1; 2; 3] |> List.map sq // let it = [1; 4; 9]

There is also the Reverse Pipe Operator which helps with order of operations.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>printf "The value is.." <| 2 + 3 // let it = "The value is..5"
</code>
<code>printf "The value is.." <| 2 + 3 // let it = "The value is..5" </code>
printf "The value is.." <| 2 + 3 // let it = "The value is..5"

This is useful because the unpiped form

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>printf "The value is.." 2 + 3 ;; error
</code>
<code>printf "The value is.." 2 + 3 ;; error </code>
printf "The value is.." 2 + 3 ;; error

would error because printf would try to evaluate "The value is.." 2 and error because there is no defined + operator. In order to make that work, use parenthesis:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>printf "The value is.." (2 + 3) // let it = "The value is..5"
</code>
<code>printf "The value is.." (2 + 3) // let it = "The value is..5" </code>
printf "The value is.." (2 + 3) // let it = "The value is..5"

As for practical use, the |> operator is incredibly useful and the bread-and-butter of many ML and ML-inspired languages such as F#, LiveScript and Elixir. <| is less common and typically only used when it increases readability.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật