Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use prototype object in factorial

  • Loading branch information...
commit 28db69def28f8f3bec3a4cac6539ded6a6dc0da1 1 parent a52287e
@doublec authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 factorial.lcf
View
10 factorial.lcf
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.