<commit_before>! Copyright (C) 2012 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors fry kernel locals math math.order
math.statistics sequences sequences.private ;
IN: sequences.windowed

TUPLE: windowed-sequence
    { sequence sequence read-only }
    { n integer } ;

INSTANCE: windowed-sequence sequence

C: <windowed-sequence> windowed-sequence

M: windowed-sequence nth-unsafe
    [ 1 + ] dip [ n>> dupd [-] swap ] [ sequence>> ] bi <slice> ; inline

M: windowed-sequence length
    sequence>> length ; inline

: in-bound ( n sequence -- n' )
    [ drop 0 ] [ length ] bi clamp ; inline

: in-bounds ( a b sequence -- a' b' sequence )
    [ nip in-bound ] [ [ nip ] dip in-bound ] [ 2nip ] 3tri ;

:: rolling-map ( seq n quot: ( slice -- elt ) -- newseq )
    seq length [<commit_msg>sequences.windowed: fixup stack effect for rolling-map.<commit_after>! Copyright (C) 2012 <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors fry kernel locals math math.order
math.statistics sequences sequences.private ;
IN: sequences.windowed

TUPLE: windowed-sequence
    { sequence sequence read-only }
    { n integer } ;

INSTANCE: windowed-sequence sequence

C: <windowed-sequence> windowed-sequence

M: windowed-sequence nth-unsafe
    [ 1 + ] dip [ n>> dupd [-] swap ] [ sequence>> ] bi <slice> ; inline

M: windowed-sequence length
    sequence>> length ; inline

: in-bound ( n sequence -- n' )
    [ drop 0 ] [ length ] bi clamp ; inline

: in-bounds ( a b sequence -- a' b' sequence )
    [ nip in-bound ] [ [ nip ] dip in-bound ] [ 2nip ] 3tri ;

:: rolling-map ( ... seq n quot: ( ... slice -- ... elt ) -- ... newseq )
    seq length [
{'fraction_non_alphanumeric': 0.13615023474178403, 'fraction_numerical': 0.009389671361502348, 'mean_word_length': 2.9929742388758784, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2387457', 'n_tokens_mistral': 566, 'n_tokens_neox': 541, 'n_words': 177}