mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-17 13:27:30 +03:00
minimized failure
This commit is contained in:
parent
28b95c6647
commit
905e674441
@ -1,28 +1,13 @@
|
||||
|
||||
use Optional None Some
|
||||
drop1 = Text.drop 1
|
||||
|
||||
namespace Sequence where
|
||||
|
||||
iterateWhile : (a -> Boolean) -> (a -> a) -> a -> [a]
|
||||
iterateWhile p f a =
|
||||
unfold a (a -> if p a then Some (a, f a) else None)
|
||||
|
||||
unfold : s -> (s -> Optional (a, s)) -> [a]
|
||||
unfold s f =
|
||||
go acc s f = case f s of
|
||||
None -> acc
|
||||
Some (a,s) -> go (acc `snoc` a) s f
|
||||
go [] s f
|
||||
|
||||
sliding : Nat -> Text -> [Text]
|
||||
sliding k t =
|
||||
use Nat.>=
|
||||
iterateWhile (t -> Text.size t >= k) (Text.drop 1) t
|
||||
|
||||
> sliding 2 "Unison"
|
||||
> drop1 "heyo"
|
||||
|
||||
---
|
||||
|
||||
gives a runtime error -
|
||||
|
||||
unison: user error (type error, expecting N, got True)
|
||||
unison: user error (type error, expecting N, got "heyo")
|
||||
|
||||
which indicates it is going to the runtime stack to get that `1` value,
|
||||
rather than pulling it from the arguments
|
||||
|
Loading…
Reference in New Issue
Block a user