Hi, > => means "take the thing on the left and substitute it for the first > parameter of the function on the right, so I thought it meant "The first parameter on the right will be subsituted with the thing on the left"?
> ('weasels') => replace('weasels','mustelids') works > > ('weasels','badgers') => replace('weasels','mustelids') DOES NOT work > > This is because a one-item sequence can be treated as the single string > value the first parameter of replace() requires, but a > greater-then-one-item sequence can't be. (This one gives you "item > expected, sequence found" if you try it from the GUI.) The following is quite similar to the 'piping' mechanism in R. I'll start experimenting with it. Thanx, Ben > ! means "take each item of the sequence on the left and pass it to the > thing on the right in turn", so > > ('weasels','badgers') ! replace(.,'weasels','mustelids') works. > > (note that replace() got its first parameter back as the context item > dot.) > > so if you take > > => array:for-each(function($idf) {array:append($idf,math:log($count div > $idf[2]) )}) > > and replace it with > ! array:for-each(.,function($idf) {array:append($idf,math:log($count div > $idf[2]) )}) > > (note the context-item dot!) > > you should at least get a different error message. > > -- Graydon >