学而不思则罔

  • foldr implementation in Clojure - [Clojure]

    2010-11-28


    (defn lazy-foldr [f coll]

        (lazy-seq

            (if-let [[x & xs] coll]

                (cons x (lazy-foldr f xs)))))

    详见Google Group
    上...

    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • critical thinking - [thinking]

    2010-04-11

    引用笑来的一段话,完全说出了去年底看《思考的技术》的感受:

    大约在1997年前后,二十五六岁的我,突然有一天发现自己竟然缺乏足够的逻辑思维能力,于是只好跑到图书馆里找答案。从“ thinking”这个词入手开始检索,发现有很多书的名字都以“critical thinking”为关键字——那之前我都不知道还有这样一个词组(可见我有多么孤陋寡闻)。于是,在一大堆名字里有“critical thi...
    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 2.77 - [sicp]

    2010-04-11

    先是一样,(magnitude z)出错, 因为显然magnitude不能处理complex, DrScheme给的错是:
        magnitude: expects argument of type <number>; given (complex rectangular 3 . 4)
    z是通过
        (define z (make-complex-from-real-imag 3 4))...
    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 2.30/2.31/2.32/2.35/2.36 - [sicp]

    2010-02-18

    Exercise 2.30. Define a procedure square-tree analogous to the square-list procedure of
    exercise 2.21. That is, square-list should behave as follows:
    (square-tree
    (list 1
    (list 2 (list 3 4) 5)
    (list 6 7)))
    (1 (4 (9 16) 25)...
    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 2.33 - [sicp]

    2010-01-05

    #lang scheme

    ; the solution for the SICP 2.33

    (define (square x)
      (* x x))

    (define (accumulate op initial seq)
      (if (null? seq)
          initial
       &n...
    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 2.21/2.23 - [sicp]

    2009-12-21

    #lang scheme

    ; the solution for the SICP 2.21

    (define (square x)
      (* x x))

    (define (square-list items)
      (if (null? items)
          '()
         ...

    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 2.17/2.18/2.19 - [sicp]

    2009-12-10

    2.17 返回一个list的最后元素的表

    #lang scheme

    (define (last-pair l)
      (if (= (length l) 1)
          l
          (last-pair (cdr l))))

    (define l (list 1 2 3 4))
    ...
    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 2.6 - [sicp]

    2009-12-04

    #lang scheme

    ; the solution for SICP 2.6

    (define zero (lambda (f) (lambda (x) x)))
                 
    (define (add-1 n)
      (lambda (f) (lambda (x) (f ...
    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 2.1/2.2/2.3 - [sicp]

    2009-12-01

    #lang scheme

    ;the solution for the SICP 2.1

    (define (make-rat n d)
      (let ((g (gcd n d)))
        (cond ((and (> n 0) (< d 0)) (cons (/ (* -1 n) g) (/ (* -1 d) g)))
        &nbs...
    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 1.40/1.41/1.42 - [sicp]

    2009-11-25

    1.40

    #lang scheme

    (define tolerance 0.0001)

    (define (fixed-point f first-guess)
      (define (close-enough? v1 v2)
        (< (abs (- v1 v2)) tolerance))
      (define (try guess)
    ...
    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 1.35/1.36/1.37 - [sicp]

    2009-11-18

    #lang scheme

    ; the solution for SICP 1.35

    (define tolerance 0.000001)

    (define (fixed-point f first-guess)
      (define (close-enough? v1 v2)
        (< (abs (- v1 v2)) tolerance))
      (...
    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 1.32/1.33 - [sicp]

    2009-11-15

    1.32 accumulate的递归和迭代解
    #lang scheme
    ; the solution for the SICP 1.32

    (define (accumulate combiner null-value term a next b)
      (if (> a b)
          null-value
        &nb...

    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • Go语言是python meet C++么? - [thinking]

    2009-11-14

    Google前两天发布了go语言

    techcrunch也以Google’s Go: A New Programming Language That’s Python Meets C++报道,不过在我看来题目应该改成Google's Go: A New Progogramming Language That's Stackless Python Meets C, 原因如下:

    1) Go语言的比较特别的地方是concurrenc...

    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 1.29/1.30/1.31 - [sicp]

    2009-11-14

    1.29 simpson求定积分

    #lang scheme

    (define (cube x)
      (* x x x))

    (define (sum term a next b)
      (if (> a b)
          0
          (+ (term a)
    &...
    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
  • SICP 1.25/1.26/1.27 - [sicp]

    2009-11-09

    1.25 使用fast-expt计算expmod的问题

    (define (expmod base exp m)
      (cond ((= exp 0) 1)
            ((even? exp)
             (remainder (square (expmod base (/ e...
    tpeng2 | 阅读全文 | 评论 0 | 编辑 | 分享 0
共2页 1 2 下一页 最后一页
Copyright © 2008 RuinStido All Rights Reserved.