Skip to content

util #

fn arange #

fn arange(n int) []int

range returns a list with int values in the interval [0, n)

fn get_many #

fn get_many[T](arr []T, idxs []int) []T

get_many returns an array containing the values in the given idxs

fn int_ints_map_append #

fn int_ints_map_append(o map[int][]int, key int, item int) map[int][]int

int_ints_map_append appends a new item to a map of slice.

Note: this function creates a new slice in the map if key is not found.

fn lin_space #

fn lin_space(start f64, stop f64, num int) []f64

lin_space returns evenly spaced numbers over a specified closed interval.

fn move_ith_to_end #

fn move_ith_to_end(mut arr []int, i int)

move_ith_to_end removes element at i from the array, and puts it at the end is O(n)(?) because we have to potentially shift all the elements if we remove the first

fn range #

fn range(start int, stop int, params RangeStep) []int

range returns a list with int values in the interval [start, stop)

fn str_flts_map_append #

fn str_flts_map_append(o map[string][]f64, key string, item f64) map[string][]f64

str_flts_map_append appends a new item to a map of slice.

Note: this function creates a new slice in the map if key is not found.

fn str_ints_map_append #

fn str_ints_map_append(o map[string][]int, key string, item int) map[string][]int

str_ints_map_append appends a new item to a map of slice.

Note: this function creates a new slice in the map if key is not found.

interface Observer #

interface Observer {
	name() string
mut:
	update()
}

Observer is an interface to objects that need to observe something the data observed by this observer is being update

struct Observable #

struct Observable {
pub mut:
	observers []Observer // list of interested parties
}

Observable indicates that an object is observable; i.e. it has a list of interested observers

fn (Observable) add_observer #

fn (mut o Observable) add_observer(obs Observer)

add_observer adds an object to the list of interested observers

fn (Observable) notify_update #

fn (mut o Observable) notify_update()

notify_update notifies observers of updates

struct RangeStep #

@[params]
struct RangeStep {
pub:
	step int = 1
}