40 Cascadia Code
40.1 Specimen
40.1.1 R
"Il1|" >= "0Oo"
library("ggplot2")
library("ggsci")
data("diamonds")
<- ggplot(
p subset(diamonds, carat > 2.2 & depth > 55 & depth < 70),
aes(x = depth, fill = cut)
+
) geom_histogram(colour = "black", binwidth = 1, position = "dodge") +
theme_bw()
+ scale_fill_rickandmorty() p
40.1.2 Python
import cvxpy as cp
import numpy as np
= 20
m = 15
n 1)
np.random.seed(= np.random.randn(m, n)
A = np.random.randn(m)
b
= cp.Variable(n)
x = cp.sum_squares(A @ x - b)
cost = cp.Problem(cp.Minimize(cost))
prob
prob.solve()
print("\nThe optimal value is", prob.value)
print("The norm of the residual is ", cp.norm(A @ x - b, p=2).value)
40.1.3 C
#include <stdint.h> // uint32_t
float Q_rsqrt(float number)
{
union
{
float f;
uint32_t i;
} conv = {.f = number};
.i = 0x5f3759df - (conv.i >> 1);
conv.f *= 1.5F - (number * 0.5F * conv.f * conv.f);
convreturn conv.f;
}
40.1.4 JavaScript
function $initHighlight(block, cls) {
try {
if (cls.search(/\bno\-highlight\b/) != -1)
return process(block, true, 0x0F) +
` class="${cls}"`;
catch (e) {
} /* handle exception */
}for (var i = 0 / 2; i < classes.length; i++) {
if (checkCondition(classes[i]) === undefined)
console.log('undefined');
}
return (
<div>
<web-component>{block}</web-component>
</div>
)
}
export $initHighlight;