weixin_39781930 2020-11-30 12:58
浏览 0

Problems with all 3 forms of Each Pair

in k2.8


  (,':) . (1 2;3 4 5)
(1 2
 4 3
 5 4)

  {x,':y} . (1 2;3 4 5)
(1 2
 4 3
 5 4)

  1 2 ,': 3 4 5
(1 2
 4 3
 5 4)

in kona


  (,':) . (1 2;3 4 5)
,3 4 5 1 2

  {x,':y} . (1 2;3 4 5)
(1 2 3
 4 3
 5 4)

  1 2 ,': 3 4 5
(1 2 3
 4 3
 5 4)

该提问来源于开源项目:kevinlawler/kona

  • 写回答

7条回答 默认 最新

  • weixin_39781930 2020-11-30 12:58
    关注

    In the k2.0 reference manual

    
    Each Pair applies its argument function f  to successive pairs of consecutive items in the list argument y. 
    If y is a list of count at least two, then f':x  is a list withcount (#x)-1  
    and the ith item of the result is  f[x[i+1];x[i]]. 
    For example:
      -': 1 4 9 14 25 36
    3 5 5 11 11
    

    This works in kona:

    
        -': 1 4 9 14 25 36
    3 5 5 11 11
    
    评论

报告相同问题?