Ah, gotcha!

That could be cool. I’ll push a commit later for that!

> On Aug 17, 2020, at 9:22 AM, Jon Harper <jon.harpe...@gmail.com> wrote:
> 
> I think Alex wanted the conditional execution of the quot.
> if the key doesn't exist in the assoc, change-at provides f as value,
> but still stores the newvalue in the assoc at the given key.
> 
> Jon
> 
>> On Mon, Aug 17, 2020 at 6:18 PM John Benediktsson <mrj...@gmail.com> wrote:
>> 
>> https://docs.factorcode.org/content/word-change-at,assocs.html
>> 
>> On Aug 17, 2020, at 8:31 AM, Alexander Ilin <ajs...@yandex.ru> wrote:
>> 
>> Hello!
>> 
>> I came up with this code, because I could not quickly find an existing word 
>> for this.
>> Did I miss it? If not, would it be a useful addition to the assocs vocab?
>> 
>> ! If key exists in the assoc, change its value with quot.
>> : ?change-value ( assoc key quot: ( value -- value' ) -- assoc' )
>>   [ swap pick set-at ] compose [ 2dup of ] dip [ drop ] if* ; inline
>> 
>> ! Usage example:
>> : ?decode-opt ( assoc -- assoc' )
>>   "opt" [ string>options ] ?change-value ;
>> 
>> 
>> ---=====---
>> Александр
>> 
>> 
>> 
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>> 
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
> 
> 
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk


_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to