Arc Forumnew | comments | leaders | submit | lojic's commentslogin
1 point by lojic 6653 days ago | link | parent | on: Can't paste Arc code out of emacs

Just got stranger. It appears to have something to do with the file name. I copied arc.arc to bja.scm and I could copy/paste. I copied bja.scm to bja.arc and couldn't copy/paste.

So changing the emacs mode has no effect on an existing buffer, but changing the file name does. I guess there's something about a .arc extension that turns off copy/paste from emacs.

edit: another datapoint - everything works fine when running emacs w/o X via: emacs -nw arc.arc

While experimenting, I received the following error after entering the following from the command line:

emacs bja.arc

"File mode specification error: (error "Autoloading failed to define function archive-mode")

-----

2 points by lojic 6653 days ago | link | parent | on: ranked-stories Bug?

You're not dumb. I'm getting the same error, and the error messages aren't very helpful. Apparently, I haven't tried the hello world app since upgrading to arc2.

Anyone have an idea of the problem? I've been looking through news.arc, and came across this:

  (mac newsop args
    `(do (pushnew ',(car args) newsop-names*)
         (opexpand defop ,@args)))

  (newsop news () (newspage user))

  (newsop ||   () (newspage user))
What is that last line doing?

-----

4 points by pg 6652 days ago | link

The last line means that localhost:8080/ does the same thing as localhost:8080/news.

-----

4 points by lojic 6653 days ago | link | parent | on: asds

This spammer should be easy to find. We're looking for someone missing their left index finger.

-----

2 points by lojic 6653 days ago | link | parent | on: Arc challenge: 8 Queens Problem

"but lojic dictates"

I prefer the word encourage :) I know it's nitpicky, but the idea was to not simply use a native print. Of course, had I required the 'pp' Ruby lib, I could have just said:

  pp stack   # => [ 1, 2, 3, ... , 8 ]

-----

2 points by partdavid 6653 days ago | link

I liked the pun in "lojic dictates", though :)

My point was more that having to put spaces in meant doing it myself rather than just io:format("~p~n", [Answer]).

-----

1 point by lojic 6653 days ago | link

Ah, I missed the pun - nice.

Your point is my point. I wanted to see how well Arc handles formatting something that didn't fit neatly into an expected pattern.

Ruby has several formatting techniques that are quite nice:

1) String interpolation. You can insert an expression into a spring by using #{expression}

2) String formatting. You can use sprintf style patterns in strings via format or the % operator. For example:

  puts "%4.1f hours" % hours
  puts "%4.1f hours and %4.1f minutes" % [hours, minutes]
So, does Arc have format now?

-----

1 point by lojic 6654 days ago | link | parent | on: Arc challenge: 8 Queens Problem

My apologies.

Apparently folks have fixated on a particular algorithm in the wikipedia article. I only linked there for a general description of the problem. Instead, I should have simply said, "write a program that produces all the solutions to the problem of placing 8 queens on a chess board so that no queen is attacking any other queen and prints the solutions as follows (i.e. the output in the OP)"

I'm not too excited about an algorithm that only finds one solution, although it is clever.

-----

2 points by lojic 6654 days ago | link | parent | on: Password trouble

Also, if you have the same userid on Hacker News, you could post a note in your profile that proves you've authenticated there which might help with the trust issues.

-----

1 point by lojic 6654 days ago | link | parent | on: Password trouble

Maybe you should let pg know your real user name, so he can help, eh?

-----

2 points by gaah 6654 days ago | link

Sorry, yes. My regular account name is Jesin, but the best proof I can offer is that while I don't have the password the account will remain inactive (unless of course someone else manages to get the password). I use that name for almost all of my online accounts, but I don't happen to have an account at Hacker News yet.

As I said, I think I put my email address on my profile for that account, so if I could access a verification-email-based password recovery system I'd be fine, but for some reason you need to be logged in to do that.

-----

2 points by lojic 6654 days ago | link | parent | on: Help link has disappeared

I see it when editing comments, but not on new submissions.

-----

2 points by lojic 6654 days ago | link | parent | on: Arc challenge: 8 Queens Problem

I took sacado's code and tweaked it a bit (Ruby's push appends and Arc's push prepends). Here's the result. If someone can get rid of my joinstr function and make the prn line closer to the Ruby version in conciseness, then I think Arc does pretty well.

For this challenge, it's important to have the output match exactly - that's why the rev is necessary and the complicated print. I do string interpolation all the time in Ruby, so I wanted to see how easy/hard it was in Arc to produce lines such as [ 1, 5, 8, 6, 3, 7, 2, 4 ]

I might as well limit the code to ArcN also.

I think the following may be the only working version of Arc code that passes this challenge so far.

Having to use point is a bit awkward, but not too bad. I particularly like the function composition such as abs:- and the more concise len.stack notation. The [ string sep _ ] notation is definitely a winner also. I'm pretty pleased with the core language so far - kudos to pg & rm.

  (def valid? (stack)
    (let q2 0
      (point return
             (each q1 (range 1 (- len.stack 1))
                   (if (or (is stack.q1 stack.q2)
                           (is (abs:- q1 q2) (abs:- stack.q1 stack.q2)))
                       (return nil)))
             t)))

  (def joinstr (lst (o sep " "))
    (if lst
        (string (car lst) (apply string (map [string sep _] (cdr lst))))
        ""))

  (def queens (stack n)
    (if (is n 8)
        (prn "[ " (joinstr (rev stack) ", ") " ]")
        (each rank (range 1 8)
              (push rank stack)
              (if (valid? stack)
                  (queens stack (+ n 1)))
              (pop stack))))

  (queens '() 0)
---

  arc> (queens '() 0)
  [ 1, 5, 8, 6, 3, 7, 2, 4 ]
  [ 1, 6, 8, 3, 7, 4, 2, 5 ]
  [ 1, 7, 4, 6, 8, 2, 5, 3 ]
  [ 1, 7, 5, 8, 2, 4, 6, 3 ]
  [ 2, 4, 6, 8, 3, 1, 7, 5 ]
  ...
  [ 8, 3, 1, 6, 2, 5, 7, 4 ]
  [ 8, 4, 1, 3, 6, 2, 7, 5 ]

-----

2 points by map 6653 days ago | link

  (def valid? (stack)
    (let i 0
      (if (or (pos stack.0 cdr.stack)
              (some (fn(x)(++ i)(is i (abs:- x stack.0))) cdr.stack))
        nil
        t)))

  (def queens (stack n)
    (if (is n 8)
      (and (prall rev.stack "[ ") (prn " ]"))
      (for rank 1 8
        (push rank stack)
        (if (valid? stack)
            (queens stack (+ n 1)))
        (pop stack))))

  (queens '() 0)

-----

2 points by almkglor 6653 days ago | link

  (def valid? (stack)
    (let i 0
      (if (or (pos stack.0 cdr.stack)
              (some [do (++ i) (is i (abs:- _ stack.0))] cdr.stack))
        nil
        t)))

-----

1 point by map 6653 days ago | link

  (def valid? (stack)
    (let i 0
      (if (or (pos stack.0 cdr.stack)
              (some [is ++.i (abs:- stack.0 _)] cdr.stack))
        nil
        t)))

  (def queens (stack n)
    (if (is n 8)
      (do (prall rev.stack "[ ") (prn " ]"))
      (for rank 1 8
        (push rank stack)
        (if (valid? stack)
            (queens stack (+ n 1)))
        (pop stack))))

  (queens '() 0)

-----

1 point by lojic 6653 days ago | link

Nice job - thx.

-----

1 point by almkglor 6653 days ago | link

  arc> (help prall)
  (from "arc.arc")
  [fn]  (prall elts (o init ) (o sep , ))
   Prints several arguments with an initial header and separated by a
      given separator. 
Above function also exists in Arc2.

Instead of (point return ...(return ...)) try using (catch ...(throw ...)).

Final nitpick: I think it's rtm, not rm, although, well, I dunno. ^^

-----

1 point by lojic 6653 days ago | link

Have you tried prall to print the output in the OP? It's awkward.

-----

1 point by map 6653 days ago | link

  arc> (help prall)
  Error: "reference to undefined identifier: _help"

-----

1 point by nex3 6653 days ago | link

help is a macro defined on Anarki.

-----


Here's a snapshot of the current votes in a more readable form:

  ****************** Python
  ************** Ruby
  *********** Java
  ********* Other
  ******* Common Lisp
  ****** Arc
  ****** C++
  ***** C
  ***** Perl
  **** Lua
  **** Scheme
  *** C#
  *** OCaml
  *** PHP
  * Haskell
  * Scala
  * Smalltalk

-----

More