]> gitweb.factorcode.org Git - factor.git/blob - extra/sequences/shifted/shifted.factor
Switch to https urls
[factor.git] / extra / sequences / shifted / shifted.factor
1 ! Copyright (C) 2013 John Benediktsson
2 ! See https://factorcode.org/license.txt for BSD license
3 USING: accessors kernel math sequences sequences.private ;
4 IN: sequences.shifted
5
6 TUPLE: shifted
7 { underlying read-only }
8 { n integer read-only }
9 { fill read-only } ;
10
11 C: <shifted> shifted
12
13 M: shifted length underlying>> length ;
14
15 M: shifted like underlying>> like ;
16
17 M: shifted new-sequence underlying>> new-sequence ;
18
19 M: shifted nth-unsafe
20     [ n>> neg + ] [ underlying>> ] [ ] tri
21     2over bounds-check? [ drop nth-unsafe ] [ 2nip fill>> ] if ;
22
23 M: shifted set-nth-unsafe
24     [ n>> neg + ] [ underlying>> ] bi
25     2dup bounds-check? [ set-nth-unsafe ] [ 3drop ] if ;
26
27 INSTANCE: shifted sequence