形式化方法:

significant bit 有效位
bitwise 按位

基础知识

算法
bit-blastting
incremental bit-blastting

应用
Fermat’s last theorem

基础知识

算法
Array Reduction Algorithm
P1 = eliminate all array write: store(A, i, x);
P2 = replace ?x.P1(x) with P1(y); // y is fresh
P3 = replace ?x.P2(x) with P2(i)/…/\P2(k);
P4 = eliminate array read in P3: A[i];
应用

lambda 函数
语法

lambda 参数列表: 表达式

参数可以有多个,但只能有一个表达式

使用 lambda 函数实现 array 接口

def lambda_array():
    def array_new():
        return lambda x: 0

    # array[index]
    def array_select(array, index):
        return array(index)

    # array[index] = element
    def array_store(array, index, element):
        # exercise 16: write code to store an "element" into the
        # "index" position of "array" by using lambda expression.

        return lambda x: element if x == index else array(x)

    # a small test case
    arr = array_new()
    assert(array_select(array_store(array_store(arr, 5, 88), 7, 99), 5) == 88)
    assert(array_select(array_store(array_store(arr, 5, 88), 7, 99), 17) == 0)
    assert (array_select(array_store(array_store(arr, 5, 88), 5, 99), 5) == 88)
    print("\033[32mSUCCESS!\033[0m")
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值