Paste: Example from http://www.reddit.com/r/programming/comments/8qlx8/expressiveness_in_modern_programming_languages/

Author: slava
Mode: factor
Date: Mon, 8 Jun 2009 08:35:19
Plain Text |
USING: assocs kernel namespaces sequences summary ;
IN: recommendation-tracker

SYMBOL: recommendations

: recommended? ( recommender business -- ? )
    recommendations get at member? ;

ERROR: already-recommended recommender business ;

M: already-recommended summary
    drop "You may only recommend the same business once." ;

: add-recommendation ( recommender business -- )
    2dup recommended? [ already-recommended ] when
    recommendations get push-at ;

: recommendation-totals ( -- totals )
    recommendations get [ length ] { } assoc-map-as ;

: init-recommendations ( -- )
    H{ } clone recommendations set ;

New Annotation

Summary:
Author:
Mode:
Body: