![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Lazy sequences
The list structure could be defined as
data Seq a = Nil | Cons a (Seq a)
The Cons
constuctor takes two arguments, so there are four different laziness variants:
Cons (Strict a) (Strict (Seq a)) -- 1. fully strict
Cons (Lazy a) (Strict (Seq a)) -- 2. lazy values
Cons (Strict a) (Lazy (Seq a)) -- 3. lazy structure
Cons (Lazy a) (Lazy (Seq a)) -- 4. fully lazy
This module implements the third variant: lazy structure, but strict values.
var ones = lazyseq.cons(1, function () { return ones; });
console.log(ones === ones.tail()); // true!
This package is originally made to optimise shrink operations in jsverify, a property-based testing library.
nil : Seq a — Empty sequence.
cons : (head : a, tail : Array a | Seq a | () → Array a | () → Seq a) → Seq a : Cons a value to the front of a sequence (list or thunk).
.isNil : Boolean — Constant time check, whether the sequence is empty.
.toString : () → String — String representation. Doesn't force the tail.
.length : () → Nat — Return the length of the sequene. Forces the structure.
.toArray : () → Array a — Convert the sequence to JavaScript array.
.fold : (z : b, f : (a, () → b) → b) → b — Fold from right.
fold nil x f = x
fold (cons h t) x f = f x (fold t x f)
.head : () → a — Extract the first element of a sequence, which must be non-empty.
.tail : () → Seq a — Return the tail of the sequence.
tail nil = nil
tail (cons h t) = t
.nth : (n : Nat) → a — Return nth value of the sequence.
.take : (n : Nat) → Seq a — Take n
first elements of the sequence.
.drop : (n : Nat) → Seq a — Drop n
first elements of the sequence.
.map : (f : a → b) : Seq b — The sequence obtained by applying f
to each element of the original sequence.
.append : (ys : Seq a | Array a) : Seq a — Append ys
sequence.
fromArray: (arr : Array a) → Seq a — Convert a JavaScript array into lazy sequence.
append : (xs... : Array a | Seq a | () → Array a | () → Seq a) → Seq a : Append one sequence-like to another.
iterate : (x : a, f : a → a) → Seq a — Create an infinite sequence of repeated applications of f
to x
: x, f(x), f(f(x))….
fold : (seq : Seq a | Array a, z : b, f : (a, () → b) → b) : b — polymorphic version of fold. Works with arrays too.
append
fold
README.md
is generated from the source with ljsmake test
, yet travis will do it for you.FAQs
Lazy sequences
The npm package lazy-seq receives a total of 5,381 weekly downloads. As such, lazy-seq popularity was classified as popular.
We found that lazy-seq demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.