Arc Forumnew | comments | leaders | submit | chrisdone's commentslogin
1 point by chrisdone 5050 days ago | link | parent | on: Multi-var function literal shorthand

I like the \n syntax, it reminds me of regexes and people are generally familiar with how that works.

    ([- \2 \1] 5 10)
    => 5

-----

4 points by chrisdone 5055 days ago | link | parent | on: Arc for Ruby programmers

  (choices '(("small" "medium" "large") 
             ("vanilla" "ultra chocolate" "lychee" "rum raisin" "ginger")
             ("cone" "cup")))

-----

1 point by lojic 5055 days ago | link

Thanks. I can't remember my motivation for the more verbose form way back when - probably misguided.

-----

3 points by chrisdone 5056 days ago | link | parent | on: The proposed : syntax

I have found s-expressions easier to edit with a smart editor than other syntaxes. Having to think again about the layout of syntax doesn't sound very appealing, but I would probably give it a try if someone implemented it.

-----


In your above example I'm not exactly sure how it is different from just saying:

arc> (+ 1 2 3 4 5) 15 arc> (in 'a 'a 'b 'c 'd 'e) t arc> (- 5 4 3) -2

I.e. what power is gained from it?

Do you have any more examples?

-----

1 point by tel 5055 days ago | link

These examples were poor, sorry. I'd only just started the tutorial and I didn't want to guess function names too much.

A slightly better, though still trivial, example:

   (map [+ 5] 
        (list (range -3 0)
              (range 1 3)
              (range 3 5)))
becomes

   (map (fn (nums) (apply + (cons 5 nums)))
        (list (range -3 0)
              (range 1 3)
              (range 3 5)))
Though, normally, you might write something akin to:

   (map (fn (nums) (+ 5 (apply + nums)))
        ...)
It's a lot like Zak's suggestion, just noting that sometimes n is infinite. Full partial application is really powerful -- especially with the general trend in Arc to have the final argument be the most dynamic one -- and I regret that I don't really have time at the moment to make an interesting example.

-----

2 points by Zak 5055 days ago | link

You're now taking a list of lists and trying to add a number to each list. That should fail - partial evaluation or no. There's no sane way for the first expression to translate in to the second.

-----

8 points by chrisdone 5056 days ago | link | parent | on: I hereby propose...

Arcinists. >_>

-----

1 point by chrisdone 5057 days ago | link | parent | on: Improve your arc REPL

Alternatively you can make MzScheme include readline in your .mzschemerc:

(when (regexp-match #rx"term" (or (getenv "TERM") "")) (dynamic-require '(lib "rep.ss" "readline") #f))

-----

5 points by chrisdone 5057 days ago | link | parent | on: some versus any

Indeed. Some implies more than one. But how many? Etc. I agree with you.

-----