2 added 1116 characters in body

p#s|let l@(h:t)!a|sum[1|e<-h:a,p e]>s=a:l![]|n<-a++[h]=t!n;_!a=[a]=(![])


Try it online!

p#s     = (![])         -- main function that takes a predicate function 'p',
-- a size 's' and a input list without a name that is
-- directly passed as the first argument to function '!'
let  l@(h:t)!a        -- function '!' is a local function (so that 'p' and 's'
-- are in scope). Takes a list 'l' of at least one element
-- 'h' (and 't' being the rest of the list) and an
-- accumulator 'a'
|sum[1|e<-h:a,p e]>s -- if 'p' holds for more than 's' elements in 'h' and 'a'
=a:l![]            --   put 'a' in front of a recursive call with the same list
--   'l' and an empty accumulator
|n<-a++[h]           -- else bind 'n' to 'h' appended to 'a' and
=t!n               --   call '!' again with 't' and 'n'
_!a=[a]               -- base case for '!'. If the input list is empty, return
--   a singleton list with 'a'


p#s|let l@(h:t)!a|sum[1|e<-h:a,p e]>s=a:l![]|n<-a++[h]=t!n;_!a=[a]=(![])


Try it online!

p#s|let l@(h:t)!a|sum[1|e<-h:a,p e]>s=a:l![]|n<-a++[h]=t!n;_!a=[a]=(![])


Try it online!

p#s     = (![])         -- main function that takes a predicate function 'p',
-- a size 's' and a input list without a name that is
-- directly passed as the first argument to function '!'
let  l@(h:t)!a        -- function '!' is a local function (so that 'p' and 's'
-- are in scope). Takes a list 'l' of at least one element
-- 'h' (and 't' being the rest of the list) and an
-- accumulator 'a'
|sum[1|e<-h:a,p e]>s -- if 'p' holds for more than 's' elements in 'h' and 'a'
=a:l![]            --   put 'a' in front of a recursive call with the same list
--   'l' and an empty accumulator
|n<-a++[h]           -- else bind 'n' to 'h' appended to 'a' and
=t!n               --   call '!' again with 't' and 'n'
_!a=[a]               -- base case for '!'. If the input list is empty, return
--   a singleton list with 'a'

1

p#s|let l@(h:t)!a|sum[1|e<-h:a,p e]>s=a:l![]|n<-a++[h]=t!n;_!a=[a]=(![])