GithubHelp home page GithubHelp logo

pony-functional-data's Introduction

pony-functional-data

Functional data structures and transformations for the Pony programming language

persistent-data/Map

A persistent immutable map based on the Hash Array Mapped Trie described by Bagwell in this paper: http://lampwww.epfl.ch/papers/idealhashtrees.pdf and inspired by Clojure persistent maps (using path copying for sharing structure).

Currently has the following methods:

  (For K: (Hashable val & Equatable[K] val) and V: Any val)

  fun size(): U64  
    
  fun apply(k: K): (V | None) ?
    
  fun get(k: K): (V | None) ?

  fun getOption(k: K): Option[V] ?

  fun getOrElse(k: K, v: V): V ?
    
  fun put(k: K, v: V): Map[K,V] ?
  
  fun contains(k: K): Bool ?

  fun remove(k: K): Map[K,V] ?

There is also a primitive called Maps with helper methods:

  //Creates an empty Map
  empty[K,V](): Map[K,V]

  //Creates a Map from an array of tuples (k, v)
  from[K,V](arr: Array[(K, V)]): Map[K,V]

persistent-data/List, Lists

Immutable linked list

Currently has the following methods:

  size(): U64

  is_empty(): Bool

  is_non_empty(): Bool

  head(): A ?

  tail(): List[A] ?

  reverse(): List[A]

  prepend(a: A): List[A]

  concat(l: List[A]): List[A]

  map[B: Any val](f: Fn1[A!,B^]): List[B] ?

  flat_map[B: Any val](f: Fn1[A!,List[B]]): List[B] ?

  for_each(f: SeFn1[A!]) ?

  filter(f: Fn1[A!, Bool]): List[A] ?

  fold[B: Any val](f: Fn2[B!,A!,B^], acc: B): B ?

  every(f: Fn1[A!,Bool]): Bool ?

  exists(f: Fn1[A!,Bool]): Bool ?

  partition(f: Fn1[A!,Bool]): (List[A], List[A]) ?

  drop(n: U64): List[A]

  drop_while(f: Fn1[A!,Bool]): List[A] ?

  take(n: U64): List[A]

  take_while(f: Fn1[A!,Bool]): List[A] ?

There is also a primitive called Lists with helper methods:

  //Returns empty List of As
  empty[A: Any val](): List[A]

  cons[A: Any val](a: A, t: List[A]): List[A]

  //Create a list from an Array of As
  //  e.g. ListT.from[U32]([1, 2, 3, 4])
  from[A: Any val](arr: Array[A]): List[A]

  flatten[A: Any val](l: List[List[A]]): List[A]

  eq[A: Equatable[A] val](l1: List[A], l2: List[A]): Bool ?

persistent-data/Option

An Option[V] is either an ONone[V] or an OSome[V]

Currently has the following methods:

  is_empty(): Bool

  is_non_empty(): Bool

  value(): V ?

  map[B: Any val](f: Fn1[V!,B^]): Option[B] ?

  flat_map[B: Any val](f: Fn1[V!,Option[B]]): Option[B] ?

  filter(f: Fn1[V!,Bool]): Option[V] ?

mutable-data/Lists

Helper methods for the "collections" package mutable List

The primitive mutable-data/Lists has the following methods:

    unit[A](a: A): List[A]

    map[A: Any #read, B](l: List[A], f: Fn1[A!, B^]): List[B]

    flat_map[A: Any #read, B](l: List[A], f: Fn1[A!,List[B]]): List[B]

    flatten[A](l: List[List[A]]): List[A]

    filter[A: Any #read](l: List[A], f: Fn1[A!, Bool]): List[A]

    fold[A: Any #read,B: Any #read](l: List[A], f: Fn2[B!,A!,B^], acc: B): B

    every[A: Any #read](l: List[A], f: Fn1[A!,Bool]): Bool

    exists[A: Any #read](l: List[A], f: Fn1[A!,Bool]): Bool

    partition[A: Any #read](l: List[A], f: Fn1[A!,Bool]): (List[A], List[A])

    drop[A: Any #read](l: List[A], n: USize): List[A]

    take[A: Any #read](l: List[A], n: USize): List[A]

    take_while[A: Any #read](l: List[A], f: Fn1[A!,Bool]): List[A]

function-types

Provides abstract functional interfaces:

    Fn0[OUT]

    Fn1[IN1: Any #read,OUT]

    Fn2[IN1: Any #read,IN2: Any #read,OUT]

    Fn3[IN1: Any #read,IN2: Any #read,IN3: Any #read,OUT]

    Fn4[IN1: Any #read,IN2: Any #read,IN3: Any #read,IN4: Any #read,OUT]

    Fn5[IN1: Any #read,IN2: Any #read,IN3: Any #read,IN4: Any #read,IN5: Any #read,OUT]  

    // Side effecting function
    SeFn1[IN1: Any #read]

pony-functional-data's People

Contributors

jtfmumm avatar

Stargazers

Redvers Davies avatar  avatar Rodrigo Torres avatar Tom Johnson avatar jiangplus avatar Nahar P avatar Andrew Prentice avatar Andrew Chou avatar  avatar Isagani Mendoza avatar  avatar  avatar Matt Keas avatar Matthew Moss avatar Michael Bradley avatar Erlend avatar gparmigiani avatar Dmitry Ledentsov avatar Denis Denisov avatar Alex Chistyakov avatar  avatar Alvin Lai avatar テンプテーション avatar  avatar Emily Mumm avatar  avatar Jeremy Huffman avatar Berkus Decker avatar  avatar Zeeshan Lakhani avatar Philipp Hitzler avatar Mateusz "Serafin" Gajewski avatar Theo Butler avatar Jason Toffaletti avatar Reini Urban avatar Nikolaus Schlemm avatar Koji Yusa avatar Grigorii Eleskin avatar Petter Aas avatar Bojan Čoka avatar Karsten Schmidt avatar  avatar Joe Eli McIlvain avatar Kamil Chmielewski avatar

Watchers

James Cloos avatar  avatar Rodrigo Torres avatar

Forkers

sheerluck

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.