package range

  1. Overview
  2. Docs
Fold on integer range

Install

Dune Dependency

Authors

Maintainers

Sources

0.8.3.tar.gz
sha256=76986a77f2e9b3046be13a5b62a781e0483405c9376671a31866da56a0ddec89
md5=7b9732f6ba03ddc22cf0b4b7bd04dbe1

README.html

README

Range Library

This small library has two goals :
   * enable to fold a sequence of integers like a list
   * split a range, making distributed computing easy

Example of usage

    (* print numbers between 100 and 200 *)
     Range.(from 100 200 |> iter ~f:(Printf.printf "%d\n"));;

     (* print sum of all values between 1 and 50 *)
     Range.(from 1 50 |> fold ~f:(+) 0 |> print_int);;
     
     (* print sum of all values between 1 and 50, adding 4 to all elements and excluding 53 *)
     Range.(from 1 50 |> map ~f:((+) 4) |> filter ~f:((!=) 53) |> fold ~f:(+) 0 |> print_int);;
     
     (* implement a factorial function *)
     let factorial n = Range.(n |> abs |> from 1 |> fold ~f:( * ) 1)
     
     API documentation available at : https://aldrikfr.github.io/range/
OCaml

Innovation. Community. Security.