Platform
Resources
Pricing
Sign in
Get started
Toan Nguyen
Workspace
Fork
Published
By
Toan Nguyen
Edited
Oct 10, 2018
Insert cell
Insert cell
Insert cell
// Usage: Y(sumFactory)([1,2,3])
function
Y
(
f
)
{
return
(
m
=>
x
=>
f
(
m
(
m
)
)
(
x
)
)
(
m
=>
x
=>
f
(
m
(
m
)
)
(
x
)
)
;
}
Insert cell
function
sum
(
[
head
,
...
tail
]
)
{
if
(
!
tail
.
length
)
return
head
;
return
head
+
sum
(
tail
)
;
}
Insert cell
function
sumFactory
(
sum
)
{
return
(
[
head
,
...
tail
]
)
=>
{
if
(
!
tail
.
length
)
return
head
;
return
head
+
sum
(
tail
)
;
}
;
}
Insert cell
function
factorialFactory
(
factorial
)
{
return
num
=>
{
if
(
num
===
0
)
return
1
;
return
num
*
factorial
(
num
-
1
)
;
}
;
}
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Y
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sum
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sumFactory
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
factorialFactory
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML