Paste: Dynamic variables from vocab to listener

Author: jleija
Mode: factor
Date: Sat, 19 Mar 2011 03:40:08
Plain Text |
! Copyright (C) 2011 jleija.
! See http://factorcode.org/license.txt for BSD license.

USING: 
    kernel
    namespaces 
    math
    io
    io.files 
    io.encodings.ascii 
    strings ;

IN: text-fu

SYMBOL: encoding
ascii encoding set-global

: current-encoding ( -- sym )
    ! encoding
    encoding get ;

GENERIC: wc-l ( file-object -- n )

M: string wc-l ( file -- n )
    current-encoding
    [ 0 [ drop 1 + ] each-line ] 
    with-file-reader ;
    

New Annotation

Summary:
Author:
Mode:
Body: