Permalink
Browse files

Use prototype object in factorial

  • Loading branch information...
1 parent a52287e commit 28db69def28f8f3bec3a4cac6539ded6a6dc0da1 @doublec committed Jul 30, 2009
Showing with 6 additions and 4 deletions.
  1. +6 −4 factorial.lcf
View
@@ -1,9 +1,8 @@
Compare overhead of object factorial computation vs non-object version
\begin{code}
-object copy
- 20000 n add-data-slot
- [
+object copy
+ [
n. 1 = [
self.
] [
@@ -12,7 +11,10 @@ object copy
factorial;. n;. * self. copy n:;.
] if
] factorial add-method-slot
-
+object copy
+ swap. parent* add-data-slot
+ 20000 n add-data-slot
+
[ factorial;. ] time.
[ 20000 fac. ] time.
abcd-bdbdca

0 comments on commit 28db69d

Please sign in to comment.