由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 这次Clojure把Scala给干了
相关主题
why Scala is terriblego channel和clojure core.async哪个好
对 (im)mutability 的误解和深度理解FP的死穴还是性能
支持我的JS OOP观点的文章来了从今天开始起,学C++!
clojure和common lisp区别大么,语法上。为什么这段程序scala慢java很多
有人用clj写web么?比如用luminus,ring这些框架criticism of Scala
1st class citizen感觉写Scala就是一种享受
FP更接近人的思维新手问,大家平时使用recursion么?感觉很酷啊
clojure高手请进板上的高人们能给科普比较functional programming language么
相关话题的讨论汇总
话题: clojure话题: scala话题: lazy话题: fib2话题: loop
进入Programming版参与讨论
1 (共1页)
p*****2
发帖数: 21240
c******o
发帖数: 1277
2
this comparison happens many times, look at the comment, scala has its
greatness.
I am recently just fascinated by scalaz.
btw, how clojure handle stack overflow for complex recursions?
I am recently studying stackless scala, wondering how clojure handle
recursive that is not tail recursive.
p*****2
发帖数: 21240
3

what do you mean complex recursion? Is loop/recur what you want?

【在 c******o 的大作中提到】
: this comparison happens many times, look at the comment, scala has its
: greatness.
: I am recently just fascinated by scalaz.
: btw, how clojure handle stack overflow for complex recursions?
: I am recently studying stackless scala, wondering how clojure handle
: recursive that is not tail recursive.

c******o
发帖数: 1277
4
no, not loop, no loop
for example mutual recursion,
or another example just try to write a insertion sort with no loop/no
mutable.


【在 p*****2 的大作中提到】
:
: what do you mean complex recursion? Is loop/recur what you want?

p*****2
发帖数: 21240
5

trampoline
Clojure is not purely functional.

【在 c******o 的大作中提到】
: no, not loop, no loop
: for example mutual recursion,
: or another example just try to write a insertion sort with no loop/no
: mutable.
:

t****a
发帖数: 1212
6
我猜想用lazy sequence(lazy-cat?)可能能做到complex stackless recusion,不过还
没试过。
c******o
发帖数: 1277
7
yes, basically generalize trampoline
it is easy to do not purely functional in scala, easier than clojure
not purely functional will give up some benefits though.
I want to master both.
sometime, it is not easy to see that happens, as some combinator will in
fact have deep nested calling stack without you know this use case when you
implement the system.
It is mostly fine for app developer, but if you want to develop a library,
it is a must have skill.

【在 p*****2 的大作中提到】
:
: trampoline
: Clojure is not purely functional.

p*****2
发帖数: 21240
8

It's awkward once you do Java interop anyway. Everything becomes mutable
immediately. Can't say which one is easier.

【在 c******o 的大作中提到】
: yes, basically generalize trampoline
: it is easy to do not purely functional in scala, easier than clojure
: not purely functional will give up some benefits though.
: I want to master both.
: sometime, it is not easy to see that happens, as some combinator will in
: fact have deep nested calling stack without you know this use case when you
: implement the system.
: It is mostly fine for app developer, but if you want to develop a library,
: it is a must have skill.

t****a
发帖数: 1212
9
尝试了,可以的。如果recursion可以表示为sequence的情形下例如fib数列,就可以用
lazy sequence来实现stackless trampline。
(declare fib2)
(defn fib1 [a b]
(lazy-seq (cons a (fib2 b (+ a b)))))
(defn fib2 [a b]
(lazy-seq (cons a (fib1 b (- a b)))))
(def fib-seq2 (fib1 0.0 1.0))
(nth fib-seq2 100000) ; it works

【在 t****a 的大作中提到】
: 我猜想用lazy sequence(lazy-cat?)可能能做到complex stackless recusion,不过还
: 没试过。

1 (共1页)
进入Programming版参与讨论
相关主题
板上的高人们能给科普比较functional programming language么有人用clj写web么?比如用luminus,ring这些框架
Clojure/West的会场几乎没有什么中国人1st class citizen
这年头有哪几个公司是用函数式编程的呢?FP更接近人的思维
关于clojureclojure高手请进
why Scala is terriblego channel和clojure core.async哪个好
对 (im)mutability 的误解和深度理解FP的死穴还是性能
支持我的JS OOP观点的文章来了从今天开始起,学C++!
clojure和common lisp区别大么,语法上。为什么这段程序scala慢java很多
相关话题的讨论汇总
话题: clojure话题: scala话题: lazy话题: fib2话题: loop