为了账号安全,请及时绑定邮箱和手机立即绑定

Seasoned Schemer一书中,第12页的scramble函数,描述是什么意思?

Seasoned Schemer一书中,第12页的scramble函数,描述是什么意思?

MMTTMM 2018-12-18 19:49:01
函数描述:The function scramble takes a non-empty tup in which no number is greater than its own index, and returns a tup of the same lenght. Each number is the argument is treated as a backward index from its own position to a point earlier in the tup. The result at each position is found by counting backward from the current position according to this index.What's the value of (scramble tup) where tup is (1 1 1 3 4 2 1 1 9 2)Answer: (1 1 1 1 1 4 1 1 1 9)
查看完整描述

1 回答

?
杨__羊羊

TA贡献1943条经验 获得超7个赞

一开始我也没看懂,后来看了函数的定义才弄明白了,新的列表的每个子元素是原来每个对应子元素的向前追溯其值个.1就代表本身,2就是前一个.

查看完整回答
反对 回复 2018-12-18
  • 1 回答
  • 0 关注
  • 749 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信