Module fungi_lang::examples [] [src]

Examples of data structures and algorithms in Fungi.

Basics

These (very small) examples demonstrate basic interaction principles of Fungi's refinement data types and computation effects:

  • basic_read_effects --- read effects track the reference cells and thunks that a Fungi program observes and forces.
  • basic_write_effects --- write effects track the reference cells and thunks that a Fungi program allocates.
  • basic_write_scope --- write scopes distinctly qualify written names for different dynamic calling contexts.
  • basic_subtyping --- subtyping permits structures with fewer names to be used in contexts that expect more names.
  • basic_existentials --- existential types permit packing names and named structures into types that approximate them.

FP Basics in Fungi

Basic patterns from functional programming (FP), in Fungi:

  • op_nat --- Simple primitives for optional natural numbers

Sequences

Sequences of natural numbers, represented as probabilistically-balanced binary trees (level trees):

  • seq_max --- finds the maximum element in a sequence.
  • seq_filter --- filters a sequence of elements, producing a new (smaller) sequence.

Sets

In progress

Sets of natural numbers, represented as probabilistically-balanced binary hash tries:

  • trie_join --- joins two sets (as tries) into a single set (as a trie).
  • trie_of_seq --- builds a set of elements (as a hash trie) from a sequence of elements (as a level tree).

Quickhull

Computes the convex hull, in sorted order, of an unordered sequence of points in 2D space.

TODO

Modules

basic_existentials
basic_read_effects
basic_subtyping
basic_write_effects
basic_write_scope
op_nat

Optional natural numbers

seq_filter

Filter a sequence of elements, producing a new (smaller) sequence

seq_max

Find the maximum element in a sequence

set_join
trie