Arc Forumnew | comments | leaders | submit | zck's commentslogin
2 points by zck 5222 days ago | link | parent | on: Remove-if-not

>1. progn in Arc ?

'do, as in the following[1]:

  (if (< (rand) 0.5)
      (do (prn "No, Mr. Bond, I expect you to die...")
          (-- mi6 007)))
Some of your questions may be answered if you read through the tutorial: http://ycombinator.com/arc/tut.txt There's stuff you won't pick up on the first time that you'll want to know later.

>2.find with a :key in Arc

An example in Common Lisp, just to make sure we're talking about the same thing:

  [1]> (find 'vader
             '((indiana-jones whip snakes)
               (vader lightsabre light-side)
               (dijkstra EWDs goto)))
  NIL
  
  [2]> (find 'vader
             '((indiana-jones whip snakes)
               (vader lightsabre light-side)
               (dijkstra EWDs goto))
             :key #'car)
  (VADER LIGHTSABRE LIGHT-SIDE)
The behavior in #2, correct? You'll have to make a function to perform the key action on the element, as in the following:

  arc> (find [is (car _) 'vader]
             '((indiana-jones whip snakes)
               (vader lightsabre light-side)
               (dijkstra EWDs goto)))
  (vader lightsabre light-side)
As a side note, you asked [2] about getting SLIME set up on Windows. I wrote up a guide on how to set it up on Linux; you can probably plunder it for information about how to set it up on Windows. I also had a few questions about your setup; it's not at all like mine.

[1]Yes, this is just 'when. Shush, it's an example.

[2]http://arclanguage.com/item?id=14958

-----

1 point by ly47 5222 days ago | link

Hi zck Thanks a lot . Problems of find with :key and progn in Arc solved. About emacs and Arc still don't work. I use emacs for common-lisp with lisp-cabinet. For an editor I use scite which i configured to work with Arc(I had to make write some scripts with AutoIt) Thanks again ly

-----

2 points by zck 5222 days ago | link

Sorry, I forgot to link my SLIME thread: http://arclanguage.com/item?id=14998

Could you answer my questions in your other thread? http://arclanguage.com/item?id=15002 It's really hard to try to help you without more details than "emacs and Arc still don't work".

-----

2 points by zck 5222 days ago | link | parent | on: Remove-if-not

Does 'keep do what you want? http://files.arcfn.com/doc/list.html#keep

-----

1 point by ly47 5222 days ago | link

Hi Thanks. 'keep is good but it does not work with my code as I use a loacl function inside before using 'keep. So what to use instead of labels or flet in ARC ? Thanks again ly

-----

4 points by waterhouse 5222 days ago | link

Like this?

  ; Common Lisp:
  (flet ((f (x y)
           (blah blah x y)))
    (remove-if-not f xs))

  ; Arc:
  (let f (fn (x y)
           (blah blah x y))
    (keep f xs))

-----

1 point by ly47 5222 days ago | link

Hi Yes it works !!! Thanks ly

-----

1 point by zck 5228 days ago | link | parent | on: Emacs+arc on windows

Worst case, you can run `M-x shell`, then inside the shell window, run `racket -f as.scm` . I assume you want to get SLIME working with Arc? I've never bothered.

If I'm confused, how do you run clisp/sbcl/ccl in Emacs?

-----

1 point by ly47 5228 days ago | link

Hi Thanks for your reply. Yes I want get slime working with Arc... I run clisp/sbcl/ccl in Emacs as follow: 1-Using lispBox or lisp-cabinet.(with slime and quicklisp) 2.Using emacs with my own .emacs configuration.(with slime) ly

-----

1 point by zck 5228 days ago | link

I do keep meaning to get SLIME set up, but haven't actually tried yet. If you list what problems you run into, people will be able to help you more easily.

-----

1 point by shader 5224 days ago | link

You know, every once in a while I consider setting up slime, or at least looking at it, but I've never used slime before and I don't really know what it offers.

What are your favorite features of slime, and why would I want to use it over just emacs + arc.el + repl-in-shell?

-----

1 point by ly47 5227 days ago | link

Hi As there is no slime support for Arc I tried to load arc.el to emacs but, it failed with this message: arc.el:411:30:Error: Required feature `cl-macs' was not provided.

-----

1 point by shader 5224 days ago | link

What version of emacs are you using? Maybe you'll need to upgrade or install cl-macs.el.

-----

1 point by ly47 5222 days ago | link

Hi I'm using emacs Emacs 23.3.1 and cl-macs.el is installed. I type arc-mode and I get Arc in the menu, but when i choose Run inferior-arc error message:error: Required feature `cl-macs' was not provide. Thanks

-----

2 points by zck 5222 days ago | link

What is arc.el? There's no arc-mode for Emacs that I know of. What are you expecting to happen when you type M-x arc ? Where did you get arc.el?

I wrote up instructions on how to get SLIME working with Arc, but I don't have a Windows box to test on. Can you translate the directions to Windows, and then see if it works for you? http://arclanguage.org/item?id=14998 Notably, you don't start SLIME by typing M-x arc-mode; you start it by typing M-x slime .

-----

1 point by ly47 5221 days ago | link

Hi https://github.com/nex3/arc/tree/master/extras ly

-----

1 point by zck 5221 days ago | link

Ah. This isn't SLIME. As akkartik said, it's likely that no one here uses it. If you want to try SLIME, follow my instructions here: http://arclanguage.org/item?id=14998

-----

1 point by akkartik 5221 days ago | link

Ah, I'd forgotten about that. It hasn't been touched in over a year (http://github.com/nex3/arc/commits/master/extras/arc.el); I'm not sure if anyone here has experience with it.

-----

2 points by shader 5216 days ago | link

I definitely use arc.el on a regular basis, though I won't claim to be familiar with the finer points of its capabilities. As far as I'm concerned, it offers reasonable highlighting and indentation for arc code; I haven't tried to get it to do much else. For most of my lisp editing needs, I rely on paredit.

-----

2 points by zck 5230 days ago | link | parent | on: Possible bug in coerce with quoted nils?

It makes for some interesting coercions:

  arc> ''nil
  (quote nil)
  arc> ''arst
  (quote arst)
  arc> (coerce ''nil 'string)
  "quote"
  arc> (coerce ''arst 'string)
  "quotearst"
I could see this being somewhat useful for printing things where nils might be involved:

  arc> (with (indiana (obj hat 'fedora weapon 'whip)
         vader (obj hat 'helmet weapon 'lightsaber)
         bond (obj weapon 'walther-ppk))
        (coerce (map [_ 'hat]
                     (list indiana vader bond))
                'string))
  "fedorahelmet"
Of course, you can easily remove 'nil from a list of things:

  arc> (with (indiana (obj hat 'fedora weapon 'whip)
         vader (obj hat 'helmet weapon 'lightsaber)
         bond (obj weapon 'walther-ppk))
        (trues idfn
               (map [_ 'hat]
                    (list indiana vader bond))))
  (fedora helmet)

-----


What exactly are you asking? Are you looking for help learning Arc, or is this a discussion on how to help people learn Arc? Do you want sample programs for anything specific?

-----

4 points by zck 5236 days ago | link | parent | on: Arc vs. Clojure on Google AdWords

Personally, I'm put off by the Leading Caps Style of Writing Unless it's a Headline, but that doesn't mean it performs worse than the alternative.

It could be cool, especially if you make a landing page specifically for the campaign. You link the Arc tutorial at the top of tryarc.org, but if you had a page that was tailored at Arc newbies, that would be a much better user experience. For example, have a special REPL that prompted the user to type something, and then recognized when they did it: "To add 1 and 7, type (+ 1 7). Now you try:"

-----

1 point by evanrmurphy 5236 days ago | link

Thanks for the feedback. The caps style is actually my present split test. I have caps and non-caps variations running for each of my 6 ads right now and will see in a few weeks how their performance compares.

I think a tailored landing page is a great idea. I worry about it not being clear enough how to get started for the people who click through.

-----

2 points by zck 5236 days ago | link

Fair enough on the caps issue. I can't argue with "if it works better...", even if I don't like it personally.

Who do you want to target with this campaign? People learning programming for the first time, people learning a Lisp for the first time, or Lispers new to Clojure (and Arc)? You'll require very different instruction pages for each group. I'd be happy to help you write something, if you're interested. I'm sure many of us here would be.

-----

2 points by evanrmurphy 5234 days ago | link

I'd love to get some collaboration from the community here.

I agree 100% about different group requiring different landing pages. Both of the ones you mentioned are good targets, I think. I'll do more keyword research to help dissect the audiences.

The beginning programmers' page is easiest, because pg's tutorial already targets them:

"This is a brief tutorial on Arc. It's intended for readers with little programming experience and no Lisp experience. It is thus also an introduction to Lisp."

All we have to do is put the tutorial in an iFrame next to the REPL, as thaddeus suggested. [1] I can take care of this one. (Eventually it would be cool to have an interactive tutorial though, as you suggested.)

Can I get your input on a page that targets a Lisper who's new to Arc? They can be coming from the Lisp dialect of your choice.

And what other audiences would you consider? Maybe people new to Lisp but coming from other programming experience, such as Ruby or JavaScript?

--

[1] http://tryarc.uservoice.com/forums/80605-general/suggestions...

-----

3 points by thaddeus 5233 days ago | link

I noticed within your feedback forum there were suggestions for REPL window size changes (for both bigger and smaller) and I got to thinking that when I wrote PetroEnergyNews (http://petroenergynews.ca/map ... which has a similar bounding box look to it) I did a bunch of experimenting with different systems, different monitors and different screen resolutions before coming up with the following optimal combinations:

  screen-x: "Narrowest" 700 
            "Narrower" 800 
            "Narrow" 900 *default*
            "Wide" 1200  
            "Wider" 1400 
            "Widest" 1600
 
  screen-y: "Shortest" 400 
            "Shorter" 500 
            "Short" 600 *default*
            "Tall" 750 
            "Taller" 900 
            "Tallest" 1200 
where the defaults were also the best suited to the iPad.

If you would like you can create an account on PetroEnergyNews then go to the user preferences to select the various combinations to get a feel for these sizes.

The "Widest" by "Tallest" setting is perfect for my 27 inch iMac screen :)

Anyways hopefully this info is helpful/useful.

[edit:

1. oops, that's only the map inset window, so it doesn't include the top and bottom bars, but still they should be easy to guesstimate at about 24px each.

2. I guess the width really doesn't matter when you can just set to 100%, but it may help with the height settings?]

-----

1 point by evanrmurphy 5233 days ago | link

Noted, thanks!

-----

1 point by zck 5240 days ago | link | parent | on: Pipes and s-expressions

Fyi, your other comment on this thread (http://arclanguage.org/item?id=14886) is dead. It was obviously a valid post, but it apparently tripped the detector.

-----

1 point by rocketnia 5240 days ago | link

I didn't see it while it was alive, so I'm curious. ^_^

-----

1 point by akkartik 5240 days ago | link

Perhaps it was deliberately deleted? I can resuscitate it if not.

-----

1 point by davidx 5239 days ago | link

I think that was a duplicate that I deleted.

-----

2 points by zck 5241 days ago | link | parent | on: Syntax.for(lisp)

I took some sample code from my solution to Project Euler #21. This function determines whether the argument n is an amicable number -- that is, if you add up all its divisors, you get a number, and then you take that number and add its divisors, and you get n. The lowest amicable pair is (220, 284). Anyway, the code:

    (def amicable (n)
         (let step (sum-divisors n)
          (and (isnt n step)
               (is n
                   (sum-divisors (sum-divisors n))))))
Translated to new-syntax:

    (def amicable (n)
         (let step n.sum-divisors()
              (and n.isnt(step)
                   n.is(n.sum-divisors().sum-divisors()))))
I don't see it as a win. The function call is taken out of the first position, and placed later in the line. This puts undue importance on the first argument. Unlike Java, Ruby, and Python, you don't even have object orientation (read: single dispatch) to make that first argument actually more important. I prefer the function to be first, as that's the most important thing in the line of code. It tells me what's going on, and how to read the line. With functions being second in the line, I have to parse more of the line before getting a grip on the overall meaning of the line.

When nesting tables in Arc, you write something like this:

    ((nested-table user-id) name)
How would this look in new-syntax?

    name.user-id.nested-table()()
or

    name.(user-id.nested-table())()
or

    (user-id.nested-table() name)
Right now in Arc, you can do this:

    nested-table.user-id.name
It seems cleaner, at least for this example.

What do you see as the advantages of this syntax, beyond the fact that people will kneejerk less to Lisp style? Can you show us some code that looks better written in new-style?

-----

1 point by Pauan 5241 days ago | link

I agree overall, but... I will note that object orientation is possible, for instance with my "object.arc" library[1]. However, I don't use the "." syntax for that either... for instance, this in JavaScript:

  foo.bar(qux);
Would be this, with my library:

  (foo<-bar qux)
However, it may be cool to be able to write "foo.bar(qux)" with my library instead. I've also considered a pretty radical idea, having every function dispatch to a method on an object. So this:

  (car foo)
Would translate to this, automatically:

  (foo<-car)
In any case, I agree that with functional style, I prefer Arc's syntax. But assuming somebody were to write/use an OOP library for Arc, I can see why they would prefer a more traditional syntax.

I think, ideally, Arc should allow you to change the syntax, on a file-by-file (expression-by-expression?) basis. Then the default could be what it is right now, but still allow people to write with whatever syntax they want. Arc isn't there yet, but I think that's a nice ideal to strive for.

---

P.S. Somewhat related, is the concept of "sweet expressions": http://www.dwheeler.com/readable/

With sweet expressions, you can write "foo(bar)" rather than "(foo bar)", but it still allows you to use "(foo bar)" when you want to. In other words, it lets you mix-and-match Lisp syntax and more traditional syntax, even within the same file. So you can use whichever one happens to be most readable at the time.

---

* [1]: https://github.com/Pauan/ar/blob/lib/object.arc

-----


The relevant thread is here: http://www.reddit.com/r/programingchallenges/comments/i1m62/...

-----

2 points by zck 5267 days ago | link | parent | on: Project to learn Arc

I've been working on how to hit a webpage in arc using the underlying scheme tcp-connect function. This code -- Racket, not Arc -- will hit google, get its source, and print it on standard out:

  (let-values ([(from-server to-server) (tcp-connect "google.com" 80)])
              (write-string "GET / HTTP/1.1\nHost: google.com\n\n" to-server)
              (close-output-port to-server)
              (do ((response (read-line from-server) (read-line from-server)))
                  ((eof-object? response))
                  (write response)
                  (newline)))
I've been having trouble getting it all to work in arc by hacking ac.scm with some 'xdefs. I can get 'tcp-connect to read just fine, but 'eof-object doesn't seem to ever return true. I'm going to try this weekend, and I'll see what I can find. Here's the working 'xdef for tcp-connect:

  (xdef tcp-connect (lambda (host port)
                      (let-values ([(from-server to-server)
                                    (tcp-connect host port)])
                        (list from-server to-server))))

-----

2 points by rocketnia 5267 days ago | link

A while ago I tried to get www.google.com using Anarki's web.arc (https://github.com/nex3/arc/blob/master/lib/web.arc). It appended a spurious "?&" to the end of the URL, but once I hacked in a fix to keep that from happening, it worked just fine. (Well, I think I encountered one more issue occasionally: If there's absolutely no response, even headers, 'parse-server-headers blocks forever.)

To read the response body, web.arc just says (tostring (whilet line (readline in) (prn line))). Apparently it there's EOF detection somewhere in this process....

Sorry I'm not providing working code, or even a reliable memory. XD I suppose I'll try things out again tonight and commit any fixes back to Anarki.

-----

1 point by rocketnia 5266 days ago | link

Oh, web.arc already worked with Google. Since the last time I tried this, I think Google must have updated to accept http://www.google.com/?&; as a legitimate home page URL.

Still, that spurious "?&" would probably break other pages, so I committed a fix: https://github.com/nex3/arc/commit/ea05adec8235fe3713b05dd9f...

Here's how to use web.arc:

  (load "lib/web.arc")
  (google "foo")              ; It comes with its own Google demo. :-p
  (get-url "www.google.com")

-----

1 point by rocketnia 5266 days ago | link

Hmm, you should not see a semicolon at the end of this line: http://&;

It seems to be a bug in the Arc Forum right now.

-----

More