Platform
Solutions
Resources
Pricing
Sign in
Sign up
Joshua Horowitz
Workspace
Fork
Public
By
Joshua Horowitz
Edited
Oct 5, 2023
Insert cell
Insert cell
refunc
=
import
(
"https://cdn.skypack.dev/@engraft/refunc@0.0.1"
)
Insert cell
refunc2
=
import
(
"https://esm.sh/@engraft/refunc@0.0.1"
)
Insert cell
square
=
refunc
.
hooks
(
(
x
)
=>
{
const
squared
=
refunc
.
hookMemo
(
(
)
=>
{
console
.
log
(
'squaring'
,
x
)
return
x
*
x
;
}
,
[
x
]
)
;
return
squared
;
}
)
;
Insert cell
{
var
mem
=
new
refunc
.
RefuncMemory
(
)
;
console
.
log
(
square
(
mem
,
3
)
)
;
// → squaring 3
// → 9
console
.
log
(
square
(
mem
,
3
)
)
;
// → 9
console
.
log
(
square
(
mem
,
4
)
)
;
// → squaring 4
// → 16
console
.
log
(
square
(
mem
,
4
)
)
;
// → 16
// But note that we only remember the very
// latest input:
console
.
log
(
square
(
mem
,
3
)
)
;
// → squaring 3
// → 9
}
Insert cell
One platform
to build and deploy the best data apps
Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
refunc
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
refunc2
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
square
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML