Arc Forumnew | comments | leaders | submit | bogomipz's commentslogin
2 points by bogomipz 6612 days ago | link | parent | on: Nitpick: Why "rem" and not "rm"?

I feel rem is a strange name too, but don't feel rm makes it any better. Actually, as others have pointed out, the function isn't really necessary since

  (rem foo my-list)
can be written as

  (keep ~foo my-list)
Personally, I think select is a better name than keep, especially when you start using it on database tables, but that's just me.

-----

4 points by almkglor 6612 days ago | link

Incidentally, keep is written (with some additional fooness) as:

  (def keep (test seq)
     (rem ~test seq))

-----

1 point by bogomipz 6610 days ago | link

Which proves that only one of them is necessary.

I'm sure the implementation could easily be reversed, so keep was the one that actually did the work.

-----

5 points by bogomipz 6616 days ago | link | parent | on: Use Apache for static files?

Just take any URL that is not defop'ed to mean a file name.

Currently, if no op is defined, the server responds with "Unknown operator.". Replace that with the code for opening a file, and if this fails, respond with a proper 404 Not Found message.

-----

3 points by pg 6616 days ago | link

That should work for text/html files.

-----

2 points by bogomipz 6615 days ago | link

By throwing in a hash table which maps from file name extensions to MIME types, it could work for other files as well.

A byte array data type for buffering would do good for performance.

-----

1 point by bogomipz 6616 days ago | link | parent | on: Updated range with step

I'll just throw in that you can simplify the nested ifs slightly like this;

  (if (is step 0) (list start)
      ((if (> step 0) > <) start end) '()
      (cons start (range (+ start step) end step)))
Also, you might want to make the function tail recursive, but that's a criticism of the original rather than your addition.

-----

1 point by bgutierrez 6616 days ago | link

Isn't this exactly the same as what I did, except with different formatting and a '() in place of a nil?...

-----

1 point by ryantmulligan 6616 days ago | link

the second line has less ifs

-----


The data is not used on the second page, but on the third.

Submit on the first page sends the data using http post. The second page just displays a link "click here", and it's when following that link the user is unable to alter the data.

-----

1 point by bogomipz 6616 days ago | link | parent | on: Unquoting

Is (quote foo) way more efficient than (quasiquote foo) ?

Is that a reason why you don't want to use quasiquote unless you're actually going to unquote something, and especially not for every literal symbol in your code?

-----

1 point by bogomipz 6617 days ago | link | parent | on: Using Common Lisp as base for Arc

Well, there are schemes that compile to machine code, like Chicken Scheme, but I guess the ultimate goal is a from scratch implementation. It's wise to postpone that until the language design stabilizes, though.

-----

1 point by elibarzilay 6616 days ago | link

MzScheme does have a JIT compiler that produces machine code. One of the reasons to use the recent version (372) is that in version 370 it switched to a precise GC which is faster and more stable. (BTW, Chicken compiles to machine code when used in batch mode.)

-----

1 point by bogomipz 6617 days ago | link | parent | on: Unquoting

I guess I already knew the answer would have to do with nested quotes, but I see it more clearly now. It's very simple really; what the plain quote buys you is the ability to unquote once instead of twice when using quote inside quasiquote.

Do people that write a lot of macros feel that's such a precious feature?

What's wrong with ''$$x ?

-----

1 point by bogomipz 6617 days ago | link | parent | on: Unquoting

Simple; '$x versus ''$x

-----

1 point by bogomipz 6617 days ago | link | parent | on: If I were in charge of Arc...

You can already do `(a b . ,others) in any Lisp. I just checked PLT, Arc and SBCL.

-----

1 point by bogomipz 6618 days ago | link | parent | on: If I were in charge of Arc...

One could also wish that (apply f args) could be written as (f . args). This makes perfect sense to me, even more so than (f @args), although logically they would mean the same.

The difference is that . is a notation for CONS, while @ may be used anywhere in a list. This means that (1 2 @others 3) cannot reuse others, and therefore shouldn't do so when the splice happens to be at the end either.

  (1 . 2) means (cons 1 2)
  (1 2 . foo) means (cons 1 (cons 2 foo))
  (1 2 @foo) is slightly more complicated as it needs to loop over foo

-----

More