`
shxiao
  • 浏览: 29786 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

知识种类

阅读更多
关于只是大致可以分为how, what, why这3中知识。 也就是所谓的"知、行、观"​​​​​

what表示的是知识是什么,通过声明式的表示方法来表示知识

what表示的如何实现知识,​​​​​​​​​​​​​​​属于工具类的知识,表示对知识的探索过程

why表示的知识存在理由,是知识的充分条件

Computer science is dealing with a different kind of knowledge -- Imperative or

"how to" knowledge. It is trying to capture the notion of a

process that causes information to evolve from one state to

another, and we want to see how we can use methods to capture the knowledge

一个命令式知识的公共模式

1:做一个猜测

2:检验猜测是否正确(检验正确时就需要what之类的知识)

3:如果正确的话,则找到结果

4:如果不正确的话,换另外一个猜测(或者在现有猜测上进行改进),跳转到第2步,直至找到正确的答案

5:最重要的是猜测的改进算法,如果不能有效的改进猜测的话,那效率将是很低的



把这个模式实例化就是计算平方根的过程​




(defn sq

 [x]

(letfn [ (abs [x] (if (< x 0) (- x) x)) (improve [guess]

     (/ (+ (/  x guess) guess) 2))

      (good? [guess]

     (< (abs (- (* guess guess) x)) 0.001))

      (sq-iter [guess]

    (if (good? guess)

guess

(recur (improve guess))))]

     (sq-iter (/ x 2))))
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics