Arc Forumnew | comments | leaders | submit | offby1's commentslogin
2 points by offby1 5946 days ago | link | parent | on: Improve this function?

topkin's thingy doesn't give the same result. Try it and see.

-----


I've long suspected arc would make a decent first language.

-----

1 point by offby1 6036 days ago | link | parent | on: Nondeterminism

If that really works, I bet it's a record for brevity.

-----

2 points by offby1 6052 days ago | link | parent | on: Poll: ssyntax

Sanctified! Can I get an "amen"?

-----

2 points by offby1 6053 days ago | link | parent | on: Bug?

As well you should be -- that's pretty subtle.

-----

1 point by offby1 6067 days ago | link | parent | on: RSS Feeds in Arc

http://code.google.com/p/rudybot/source/browse/trunk/planet-... might have a relevant bit of code, around line 110

-----

2 points by offby1 6069 days ago | link | parent | on: Help with a function

This might make life worth living again:

  diff --git a/strings.arc b/strings.arc
  index a28b2fe..1d3b010 100644
  --- a/strings.arc
  +++ b/strings.arc
  @@ -83,7 +83,7 @@
       (if (isa pat 'fn)
           (for i start (- (len seq) 1)
             (when (pat (seq i)) (throw i)))
  -        (for i start (- (len seq) (- (len pat) 2))
  +        (for i start (- (len seq) (len pat) 1)
             (when (headmatch pat seq i) (throw i))))
       nil))

-----

1 point by wfarr 6069 days ago | link

Works for me as well.

-----

1 point by offby1 6075 days ago | link | parent | on: Anyone here going to Startup School?

"Arcistas"?

-----

1 point by almkglor 6075 days ago | link

Anarkist?

oops ^^

-----


Now why on Earth would arc be _faster_ than mzscheme?!

-----

3 points by sacado 6097 days ago | link

Hmm... I confirm what I said. In a silly benchmark involving fibonacci, prime numbers and factorial (only real world examples as you can see ;), mzscheme took about 1mn35s and Arc (with fast numerical operations) only 58s. No doubt time is not broken as I used the Unix command this time. It also means that these 58s. include the 3s. on Arc startup. The actual time is closer to 55 s. No, if anyone has an idea about why a given code can be faster in Arc...

-----

1 point by kens1 6097 days ago | link

When I did the earlier Fibonacci benchmarking, I found it useful to take the code generated by ac, and run it inside mzscheme. (Note that :a will drop you from Arc to Scheme.) That is, running the exact same code that Arc does, just from the Scheme REPL. (This should take the same time as running in Arc, or else something is very wrong.) Then I could tweak the code a function at a time evolving from the Arc-generated code to the Scheme code, and see where the time was going.

Overall, it makes no sense that Arc would be faster. But it would be very interesting to find out why you're getting those results. Could there be some subtle algorithm difference, maybe lack of tail recursion, in the Scheme version?

-----

1 point by sacado 6096 days ago | link

Ok, I tried that. Running the fib code in a mzscheme REPL is slower than in an Arc REPL. But, if once in Arc REPL you type :a (and get to the mzscheme REPL with Arc functions loaded), the same Scheme code is then a little faster than the Arc counterpart. That means there is something in ac.scm that speeds up mzscheme computations. Maybe the fact that it's embedded in a module ? I really don't know, but at least this is not an aberration anymore.

-----

3 points by sacado 6097 days ago | link

I really don't know. It just is... It might be a bug in the time function, or for some reason the ugly code produced by the ac function gets optimized better than the simple mzscheme code...

Anyway, that's only a micro-benchmark. I'm trying to confirm this with more tests... I guess mzscheme will eventually be slightly faster than Arc.

-----

1 point by offby1 6101 days ago | link | parent | on: Suggestion: constructors

For what it's worth, mzscheme's "hash-table-get" solves this by giving you an optional "default" value -- if you omit the value, then you get an exception; if you specify the value, then you just get that value -- unless the value is a procedure, in which case it calls that procedure. The procedure can raise your favorite exception, or perhaps _insert_ something into the hash table, or ... anything you want. This seems like a nice balance between simplicity and flexibility.

-----

More