您正在查看 "函数阴阳" 分类下的文章
2008-11-17 14:30
Factor是啥?Factor = Forth的语法 + Scheme的FP精神 + Common Lisp的对象系统 + Smalltalk的镜像环境……总之就是像我这样的伪高手想装神弄鬼的时候最适合给大家推荐的东西……
以下地址是Factor作者Slava Pestov在上个月的Google Techtalk里面对Factor的简介,很不错,可以作为factor的入门讲座的说~
http://www.youtube.com/watch?v=f_0QlhYlS8g
|
2008-08-18 12:15
Basically Python is lexically scoped like almost all other mainstream languages, that is, certain language facilities like the 'class', 'def' statements will create a new scope for their own code blocks. And when names are looked up, the intepreter goes up the nested scope levels and stop at the first one it encounters. It sounds fine, but things would go a little confusing when we bind values to variables.
Which scope will the newly binded variable be in?
The answer is actua |
2008-08-18 12:14
Now I settled in python, as "There is obviously ONE way to do it." sounds sweet, and there won't be endless "end"s for me to deal with. Meanwhile, the library support is great compared to the "exotic" languages I play with, especially when I am to do some GUI programming.
I'm quite happy learning how python handles the 'value vs reference' and 'equality check' problem.
In C and C++, we have stack-based objects and heap-based objects, and referenc |
2008-06-18 11:29
因为今天的一条留言,赫然发现自己读SICP已经是两年前的事情了~
两年。
最近PLT Scheme V4发布了,pair已经变成了默认不可更改的结构,这对于程序的优化应该是会有帮助的,当然前提是能够保证使用函数式方法写代码。Chicken也正在向纯卫生的实现转变,等到Chicken 4.0的module system定型之后就下载个玩玩,不过这样一来库就成问题了,V3的eggs仓库还是蛮丰富的说。可惜的只是,到现在为止,我还没有用Scheme写过什么不trivial的程序……或者说,我写过什么让自己能很自信地写上CloudiDust Presents的东东么?
|
2007-10-26 15:48
最近看到一则消息说,微软决定把F#进行商业化推广,也就是说,在经历了N年的等待之后,函数式编程的大规模应用时代很可能就要开始了,正如N年前OO刚开始流行时那般。虽说又要算是M$的“功劳”,但在如今的社会,没有大公司推动,要使一门语言进入主流确实很难。
F#虽然也是Microsoft Research荣誉出品(某种意义上,Haskell都能算是……两个Simon都在MR Cambridge的说),不过似乎一开始就是为了能进入主流而设计的(不像Haskell主要定位于研究),作为ML(尤其是Caml)的衍生语言,F#具有栖身于.NET Framework |
2007-05-26 15:40
2007-03-15 22:59
Sharing doesn't exist in the real world
I'm an ex physicist. In classical physics and ignoring quantum effects two objects in the real world cannot exist in the same place at the same time.
If we have two objects they must be at different places. Now the only way one object can interact with another is by sending it a message (say by a light ray). If this light ray encodes some information about a state change, then as far as the receiving object is concerned |
2007-03-10 00:36
This translation is posted with the permission of the author, Simon Peyton Jones. The English-language version appears in the book “Beautiful Code”, edited by Greg Wilson, published by O’Reilly, to appear in 2007.
本(中文)译本的发布行为,已经由原作者Simon Peyton Jones许可。原英文版本将载于《美丽的代码》,编辑为Greg Wilson,出版商为O'Reilly,将于2007年出版。
美丽的并发 Beautiful Concurrency
作者:Simon Peyton |
2007-03-10 00:31
点此阅读第一部分(Click here for Part A)
4. 圣诞老人问题
我将展示一个完整可运行的STM并发程序,这是一个相当知名的例子:所谓的 *圣诞老人问题*(Santa Claus Problem)[注10],最初由Trono[14]所描述:
圣诞老人总是在睡觉,直到他被度假归来的全部九只驯鹿,或是他的十个小精灵工人中的三个(任意的)叫醒。若是被驯鹿所叫醒的,那么圣诞老人将把它们拴到他的雪橇上,出发去分发玩具, |
2007-03-01 15:42
想为自己的译文争取一个合法地位,因为严格地说,我是不能随便在“翻译”这一类衍生作品上应用Creative Commons许可证的,它们并不(完全是)我的作品呀。于是发了一封信去,结果当晚(就是昨天十点半,英国时间是下午两点半),Simon就回了封信给我,曰,贴之可矣。于是放心了,也对自己的英语书面表达能力稍有了些信心,呵呵。
(其实现在的时间是3月10日凌晨00:45,刚去堕落了一下,玩命令与征服3,选了NOD,对付龟缩GDI,由于对方防守太严密,坦克部队损失惨重……只能用迷魂开路……二十多架轰炸机乱飞还是很壮 |
2007-02-22 21:03
估计也是最基本的Metacircular Evaluator了……
原来手册上的版本是用Lisp 1.5写的(废话……),这里的实现用的是Common Lisp语法。
BTW:没想到Lisp 1.5的语法反而是比较不像我印象中的Lisp呢……
(defun eval. (e a) (cond ((atom e) (assoc. e a)) ((atom (car e)) (cond ((eq (car e) 'quote) (cadr e)) ((eq (car e) 'atom) (atom (eval. (cadr e) a))) ((eq (car e) 'eq) (eq (eval. (cadr e) a) |
2007-02-13 22:26
这些天一直浸泡在奇妙的Metacircular Evaluator中,到今天已经完成了前三节,写了四个小求值器,学到了不少东西,这里无法一一列举了。本来还在看逻辑编程那一节,相当的晕,暂且休息一下,就详细说说“符号”吧,其他的东东要解释清楚牵扯的就多了:
在写Metacircular Evaluator的过程中,我们打交道最多的东西就是所谓“符号”了,而不是像用其他语言写此类程序时那样,主要是处理字符串。由于scheme程序即数据,数据即程序的BT特性,让symbol成了一个相当让人头痛的东西——虽然说到底真正的 |
2007-02-09 00:16
Scheme rocks! I am busy hacking my little dumb metacircular evaluator today, enjoying even every messy error message bouncing out here and there. Half a page of code to rule them all! (Remember how Alan Kay commented on Lisp 1.5?) What an amazing experience!
Section 4.2 of SICP describes an approach to change the way our metacircular evaluator applies procedures, so we can now use normal-order evaluation instead of applicative-order evaluation.(Or lazy evaluation instead of eager eval |
2007-02-04 13:53
惰性语言 vs 非惰性语言中的惰性列表
今天做SICP习题的时候,碰到一个由于语言懒惰的程度而产生的有些晦涩的问题,郁闷了多时才解决,因此有了些心得。
闲话少说,我们的目标是:构造出全部的,具有形式(i, j), 满足i <- N*, j <- N*,且i <= j的值对。
很显然,我们可以用两个正整数流构造出结果流pairs,书上给出的示例解法是这样:
(define (pairs s t)
(cons-stream
(list (stream-car s) (stream-car t))
(interleave
|
2007-02-01 19:57
今天照例到Haskell.org上刷一遍,结果看到有更新,其中最后一项居然是我期待已久的三大牛人Hudak,Hughes和Peyton Jones合著的论文《Haskell的历史》,于是下载回来拜读。
1月25日完成的,新鲜热辣呀!
原来以为Haskell是Miranda的衍生产物,原来并不是直系血亲啊……
读了一部分之后,对于Haskell设计中的一些取舍权衡也就有了了解,比如说pattern guards为什么不使用Miranda风格,也就是常用的数学函数定义式的风格,而使用现在的这种风格等,确实很有意思呢。
最后说一句,catagory |
|
|