Paste: code works inline but not in a definiton

Author: kerneis
Mode: factor
Date: Thu, 16 May 2013 16:11:26
Plain Text |
: seq-max ( seq -- n ) [ ] [ max ] map-reduce ;
: max-index ( seq -- n ) [ seq-max ] keep index ;
: map-max ( seq quot -- elt )
    [ map max-index ] 2keep drop ?nth ;

! This fails with: cannot apply "call" to an input parameter of a non-inline word
{ 1 2 3 } [ 1 + ] map-max

! But this works (expanding the definition of map-max)
{ 1 2 3 } [ 1 + ] [ map max-index ] 2keep drop ?nth

New Annotation

Summary:
Author:
Mode:
Body: