howl-0.1.0.0: A small Wolfram Language interpreter and symbolic rewriting library
Safe HaskellNone
LanguageGHC2021

Howl.Util

Description

Small utility helpers used across the implementation.

Synopsis

Documentation

splitsK :: Seq a -> (Seq a -> Seq a -> r -> r) -> r -> r #

Stream splits of xs into (t1,t2) where xs == t1++t2. Calls the step function once per split; allows early exit.

splits1K :: Seq a -> (Seq a -> a -> Seq a -> r -> r) -> r -> r #

Stream splits of xs into (t1, t, t2) where xs == t1++[t]++t2. Calls the step function once per split; allows early exit.

subSequencesK :: Seq a -> (Seq a -> Seq a -> r -> r) -> r -> r #

Stream all (subSeq,rest) pairs where subSeq is a subsequence of xs. Enumerates in increasing order of subsequence length. For long sequences, only subsequences up to a small size are generated.

pattern Solo :: a -> Seq a #

A sequence of length 1 (bidirectional pattern synonym)

pattern Pair :: a -> a -> Seq a #

A sequence of length 2 (bidirectional pattern synonym)

mapMaybeSeq :: (a -> Maybe b) -> Seq a -> Seq b #

Map a function over a Seq, collecting Just results