Skip to content

Instantly share code, notes, and snippets.

View Lotterleben's full-sized avatar

Lotte Steenbrink Lotterleben

View GitHub Profile
@Lotterleben
Lotterleben / confusions.md
Last active September 23, 2020 13:54
Learning Rust Log

Confusions

  • why will a large number not automatically be inferred as i128?
    • turns out this is a design decision:
    • also I learned through this: integer literals without fixed size info (i.e. iize and usize) are not aliases for well-sized types, they are types of their own and will not be implicitly cast (so you'll probably need ti be specific about int sizes in practice anyway, which I really like)

if let syntax

is the = an assignment or an equiality check? Why would I use if let if I can just assign whatever I need inside of a regular if block? Does if let Some(i) = number mean "if i has a value (i.e. is not None) then branch here and henceforth call i number within the following {} block"? Maybe I'm missing something but I feel like this is not a common pattern and shouldn't be brushed over while explaining what if-else/for/while look like in Rust.

  • EDIT: Oh wait, I think it's the other way around! If number is a Some, then refer to the contents of this Some as i in
/* (TODO only guaranteed for AODVV2_DEFAULT_METRIC_TYPE!)*/
bool is_loop_free = node_data->metric <= rt_entry->metric;
int stale = seqnum_cmp(node_data->seqnum, rt_entry->seqnum);
if ((stale == 1) /* New info is more recent and MUST be used */
|| ((stale == 0) && (node_data->metric < rt_entry->metric)) /* New info offers a better route and SHOULD be used */
|| ((stale == 0) && (node_data->metric >= rt_entry->metric) /* Route is not an improvement, */
&& (rt_entry->state == ROUTE_STATE_INVALID) /* but repairs an invalid route */
&& is_loop_free /* and contains no loops */
) {
#include <stdio.h>
enum Foo {
A,
B,
C
};
int test[] = {
[A] = 3,

how to test Lotte's NDP drama

setup

git clone git@github.com:Lotterleben/RIOT-AODVv2.git aodvv2
mkdir riot
cd riot
git clone git@github.com:Lotterleben/RIOT.git RIOT
cd RIOT
git checkout aodv_less_broken
# how to test Lotte's NDP drama
## setup
git clone git@github.com:Lotterleben/RIOT-AODVv2.git aodvv2
mkdir riot
cd riot
git clone git@github.com:Lotterleben/RIOT.git RIOT
cd RIOT
git checkout aodvv2-clean
#include <stdio.h>
#include <stdint.h>
#include <math.h>
int main(void){
uint32_t foo = pow(2, 3);
printf("testtest: %d\n", foo);
}
#! /usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
class Ctabwindow:
#warning: I never said it was going to be pretty.
# todo? callbacks, sicherstellen dass nur zahlen "," und ":" eingegeben werden,
lambdapiraten :: (FunctionalLanguage t) => [Piraten] -> [t] -> #win
main = do
let win = lambdapiraten [@alios, @lotterleben..] [Haskell,Erlang,LISP,ML,ocaml,Miranda,F#,Scala..]
freu win