Platform
Resources
Pricing
Sign in
Get started
David
I'm a Mechanical Engineer. I do Mechanical Design, Simulation, 3D Printing, Teaching and numerical programming in GNU Octave, Python and JavaScript.
Workspace
Fork
Public
By
David
Edited
May 29, 2023
Insert cell
Insert cell
mat
.
import
(
{
index
:
math
.
factory
(
'hi'
,
[
]
,
math
.
index
)
}
,
{
override
:
true
}
)
Insert cell
test3
=
math
.
factory
(
'hi'
,
[
math
.
index
]
,
math
.
index
)
Insert cell
test3
.
Insert cell
A
=
[
10
,
20
,
30
,
40
]
Insert cell
select
=
[
false
,
true
,
true
,
false
]
Insert cell
m
.
evaluate
(
`
A = [10, 20, 30, 40]
# A>20
# A[[false, true]]
# A[[true, false, true, false]]
`
)
Insert cell
test
=
math
.
typed
(
{
'...Array'
:
(
x
)
=>
x
,
'...number'
:
(
x
)
=>
math
.
add
(
2
,
x
)
}
)
Insert cell
test2
=
(
...
x1
)
=>
x1
.
map
(
math
.
typed
(
'hi'
,
{
'Array'
:
(
x
)
=>
x
,
'number'
:
(
x
)
=>
math
.
add
(
2
,
x
)
}
)
)
Insert cell
[
1
,
2
]
.
map
(
x
=>
x
)
Insert cell
test2
(
1
,
[
1
]
,
2
+
2
)
Insert cell
test
(
[
1
]
,
[
1
]
,
[
1
]
)
Insert cell
test
(
1
,
1
,
1
)
Insert cell
convertBooleanIndex
(
select
)
Insert cell
mat
.
index
(
[
1
,
2
]
)
Insert cell
mat
.
index
(
select
)
Insert cell
math
.
index
(
convertBooleanIndex
(
select
)
)
Insert cell
mat
.
subset
(
A
,
mat
.
index
(
select
)
)
Insert cell
math
.
subset
(
A
,
math
.
index
(
[
1
,
2
]
)
)
Insert cell
math
.
subset
(
A
,
math
.
index
(
convertBooleanIndex
(
select
)
)
)
Insert cell
isBooleanIndex
=
math
.
typed
(
// checks if all elements in an index are boolean
{
'Array'
:
index
=>
index
.
every
(
e
=>
math
.
isBoolean
(
e
)
)
,
'any'
:
(
)
=>
false
}
)
Insert cell
convertBooleanIndex
=
math
.
typed
(
{
// converts [true, false, true, false] to [0,2]
'Array'
:
(
x
)
=>
math
.
filter
(
math
.
range
(
0
,
x
.
length
)
,
(
e
,
i
)
=>
x
[
i
]
)
.
toArray
(
)
}
)
Insert cell
[
true
,
false
,
true
]
.
map
(
)
Insert cell
mat
=
{
let
mat
=
math
.
create
(
)
mat
.
import
(
{
index
:
math
.
typed
(
{
'...Array'
:
(
index
)
=>
math
.
index
(
isBooleanIndex
(
index
)
?
convertBooleanIndex
(
index
)
:
index
)
,
}
)
}
,
{
override
:
true
}
)
return
mat
}
Insert cell
m
=
mat
.
parser
(
)
Insert cell
math
=
require
(
"mathjs"
)
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
test3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
A
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
select
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
test
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
test2
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
isBooleanIndex
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
convertBooleanIndex
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mat
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
m
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
math
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML