Avatar

simonw

3 public vals
Joined March 6, 2023
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { jsPython } from "npm:jspython-interpreter";
const script = `
def mapFunction(r, i):
v = r * i
return v
x = [1, 2, 3, 4]
x
.map(mapFunction)
.filter(r => r * r)
.join(",")
`;
const interpreter = jsPython();
const result = await interpreter.evaluate(script);
console.log(result);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
const jsPython = async () => {
const { jsPython } = await import("npm:jspython-interpreter");
const script = `
def mapFunction(r, i):
v = r * i
return v
x = [1, 2, 3, 4]
x
.map(mapFunction)
.filter(r => r * r)
.join(",")
`;
const interpreter = jsPython();
return interpreter.evaluate(script);
};
console.log(await jsPython());
}
1
2
3
4
5
6
7
8
9
import { fetch } from "https://esm.town/v/std/fetch";
export async function latestBlogContent() {
return (
await fetch(
"https://datasette.simonwillison.net/simonwillisonblog.json?_shape=array&sql=select+%27entry%27+as+type%2C+title%2C+created%2C+%27https%3A%2F%2Fsimonwillison.net%2Fe%2F%27+%7C%7C+id+as+url+from+blog_entry%0D%0Aunion+all%0D%0Aselect+%27blogmark%27+as+
)
).json();
}
Next