Paste: change-at does one lookup

Author: rien
Mode: factor
Date: Fri, 14 Oct 2011 02:07:49
Plain Text |
! I'm a newbie and this hasn't been benchmarked, but here it is.
! https://github.com/slavapestov/factor/issues/251

( scratchpad ) : my-change-at ( ..a key assoc quot: ( ..a value -- ..b newvalue ) -- ..b )
[ key@ drop 1 + swap ] dip change-nth ; inline
( scratchpad ) "b" [ 90 + ] H{ { "a" 0 } { "b" 1 } { "c" 2 } } [ swap my-change-at ] keep

--- Data stack:
H{ { "a" 0 } { "b" 91 } { "c" 2 } }
( scratchpad ) 

New Annotation

Summary:
Author:
Mode:
Body: