USING: arrays assocs byte-arrays combinators io
io.encodings.binary io.streams.byte-array io.streams.string
-kernel linked-assocs math math.parser sequences strings ;
+kernel linked-assocs math math.parser sequences sequences.extras strings ;
IN: bencode
GENERIC: >bencode ( obj -- bencode )
"e" read-until CHAR: e assert= string>number ;
: read-list ( -- obj )
- [ read-bencode dup ] [ ] produce nip ;
+ [ read-bencode ] loop>array ;
: read-dictionary ( -- obj )
[
- read-bencode [ read-bencode 2array ] [ f ] if* dup
- ] [ ] produce nip >linked-hash ;
+ read-bencode [ read-bencode 2array ] [ f ] if*
+ ] loop>array >linked-hash ;
: read-string ( prefix -- obj )
":" read-until CHAR: : assert= swap prefix
USING: accessors alien alien.accessors alien.c-types alien.data
alien.enums alien.strings arrays assocs combinators fry
io.encodings.string io.encodings.utf8 kernel literals math
-math.bitwise math.parser pcre.ffi regexp sequences splitting strings ;
+math.bitwise math.parser pcre.ffi regexp sequences
+sequences.extras splitting strings ;
IN: pcre
ERROR: bad-option what ;
GENERIC: findall ( subject obj -- matches )
M: compiled-pcre findall
- [ <matcher> [ findnext dup ] [ ] produce 2nip ]
+ [ <matcher> [ findnext ] loop>array nip ]
[ nametable>> rot [ parse-match ] 2with { } map-as ] 2bi ;
M: string findall
USING: accessors byte-arrays classes combinators io
io.binary.fast io.encodings.binary io.files
io.streams.byte-array kernel locals math math.order
-math.statistics sequences sets ;
+math.statistics sequences sequences.extras sets ;
IN: shapefiles
4 read [ be> 4 read be> read-shape record boa ] [ f ] if* ;
: read-records ( -- records )
- [ read-record dup ] [ ] produce nip ;
+ [ read-record ] loop>array ;
: read-shp ( -- header records )
read-header read-records ;
4 read [ be> 4 read be> index boa ] [ f ] if* ;
: read-indices ( -- indices )
- [ read-index dup ] [ ] produce nip ;
+ [ read-index ] loop>array ;
: read-shx ( -- header indices )
read-header read-indices ;