% Let's build a binary tree!
Let's build a binary tree of strings in Rust. To recap, each node in a binary tree:
- must have a value
- may or may not have left and/or right children
So we can describe a single node like this:
% Let's build a binary tree!
Let's build a binary tree of strings in Rust. To recap, each node in a binary tree:
So we can describe a single node like this:
fn main () { | |
let number: f64 = 20.; | |
// Perform a pipeline of options. | |
let result = Some(number) | |
.map(inverse) // Described below. | |
.map(double) | |
.map(inverse) | |
.and_then(log) // Described below. | |
.map(square) | |
.and_then(sqrt); |
use std::str::FromStr; | |
fn main () { | |
let mut input = "15 Bear".split(' '); | |
// Need to pull the number and parse it. | |
let number = input.next() | |
// Process Option<&'static str> to Option<int> | |
.and_then(|x| i32::from_str(x).ok() ) | |
.expect("Was not provided a valid number."); | |
// The next token is our animal. |
My typical setup for a development box in VirtualBox uses two NICs. The first uses NAT to allow the box to communicate with the outside world through my host computer’s network connection. (NAT is the default, so shouldn't require any setup.) The second is a "host-only" connection that allows my host and guest to interact.
To create a host-only connection in VirtualBox, start by opening the preferences in VirtualBox. Go to the "Network" tab, and addd a Host-only Network. Modify the host-only network, and disable DHCP. Make a note of the IP address. (Feel free to set the IP address as well, if you like.)
Next, assign this host-only adapter to the virtual machine. Select the VM and press "Settings". Go to the "Network" tab, and select "Adpater 2". Enable the adapter, set it to a "Host-only Adapter", and select the adpater you created above.
# | |
# The official PVE docs on how to prepare cloud-init templates: | |
# https://pve.proxmox.com/wiki/Cloud-Init_Support#_preparing_cloud_init_templates | |
# | |
# Additional guides and resources: | |
# https://dae.me/blog/2340/how-to-add-an-existing-virtual-disk-to-proxmox/ | |
# https://pve.proxmox.com/pve-docs/qm.1.html | |
# use the Qemu/KVM Virtual Machine Manager to import the disk | |
qm importdisk 107 Univention-App-kopano-core-KVM.qcow2 local-lvm |
//> using dep "org.http4s::http4s-scalatags::0.25.2" | |
//> using dep "org.http4s::http4s-dsl::0.23.23" | |
//> using dep "org.http4s::http4s-ember-server::0.23.23" | |
//> using dep "org.tpolecat::skunk-core::0.6.0" | |
//> using dep "com.dimafeng::testcontainers-scala-postgresql::0.41.0" | |
//> using dep "com.outr::scribe-slf4j::3.12.2" | |
import skunk.*, codec.all.*, syntax.all.* | |
import cats.effect.* | |
import scalatags.Text.all.* |