我在网上找到了本课的代码(http://groups.csail.mit.edu/mac/ftpdir/6.001-fall91/ps4/matcher-from-lecture.scm),我有一段时间了试图调试它.该代码看起来与Sussman所写的相当:
;;; Scheme code from the Pattern Matcher lecture
;; Pattern Matching and Simplification
(define (match pattern expression dictionary)
(cond ((eq? dictionary 'failed) 'failed)
((atom? pattern)
(if (atom? expression)
(if (eq? pattern expression)
dictionary
'failed)
'failed))
((arbitrary-constant? pattern)
(if (constant? expression)
(extend-dictionary pattern expression dictionary)
'failed))
((arbitrary-variable? pattern)
(if (variable? expression)
(extend-dictionary pattern expression dictionary)
'failed))
((arbitrary-expression? pattern)
(extend-dictionary pattern expression dictionary))
((atom? expression) 'failed)
(else
(match (cdr pattern)
(cdr expression)
(match (car pattern)
(car expression)
dictionary)))))
(define (instantiate skeleton …Run Code Online (Sandbox Code Playgroud) 我遇到了一个有趣的问题,即我的视频是无法在后iPad的播放.appendTo或.detach.它显示一个播放按钮,但是当按下播放按钮时,没有任何反应.
Jsfiddle http://jsfiddle.net/LHTb5/1/
HTML
<video id="video1">
<source id="mp4" src="https://s3.amazonaws.com/s3hub-1b3c58271cb3e0dfa49d60cae0ac8b86ade30aed6294bdb5fe682e2bf/HTML5/sintel_trailer-480.mp4" type="video/mp4"/>
</video>
<div id="new"></div>
Run Code Online (Sandbox Code Playgroud)
使用Javascript
?$(document).ready(function(){
$("#video1").appendTo($("#new"));
});?
Run Code Online (Sandbox Code Playgroud)
编辑
好的伙计们,对于什么是有效的,什么是无效的,有一些混乱.让我让它变得非常简单.
http://jsfiddle.net/LHTb5/2/ <---有效
http://jsfiddle.net/ecbUP/ <----不起作用
与html,标签或自动播放没有任何关系.这只是一个简单的事情,让iPad无法播放.我只是想知道为什么,或者如何做.appendTo或者.detach让它工作.
有人告诉我,我的代码应遵循O(logn)+ O(n)的复杂性指南.当提示澄清时,我被问到"代码的复杂性:)"无论如何,除了提供的任何澄清之外,我们将不胜感激.
在下面的代码中,我试图了解变量如何whatami获得其值.在遵循逻辑的过程中,我看到过程(lambda (y) (/ x y))是我传递给方法的参数average-damp,并在该方法中表示为变量f.似乎(/ x y)并且(average (f whatami) whatami)需要执行,但我无法弄清楚执行的顺序.任何帮助表示赞赏.
(define (average x y)
(/ (+ x y) 2))
(define (fixed-point f start)
(define tolerance 0.00001)
(define (close-enuf? u v)
(< (abs (- u v)) tolerance))
(define (iter old new)
(if (close-enuf? old new)
new
(iter new (f new))))
(iter start (f start)))
(define average-damp
(lambda (f)
(lambda (whatami) (average (f whatami) whatami))))
; square root with average …Run Code Online (Sandbox Code Playgroud) 今晚看到Python的一些意外行为.为什么以下打印出"不相等"?!
num = 1.00
num -= .95
nickel = .05
if nickel != num:
print 'not equal'
else:
print 'equal'
Run Code Online (Sandbox Code Playgroud)