Arc Forumnew | comments | leaders | submit | jsgrahamus's commentslogin

I started using ansi-term in emacs to launch a shell file which wrapped rlwrap around the file I wished to execute. Turns out that M-x no longer works in that buffer.

reply

5 points by jsgrahamus 2 days ago | link | parent | on: Hosting Arc app on Heroku?

Heroku allows for custom buildpacks.

Also found this article, which may be helpful:

https://lexi-lambda.github.io/blog/2015/08/22/deploying-rack...

reply

4 points by jsgrahamus 2 days ago | link | parent | on: Accessing Racket from anarki

Thanks, guys. This is great!`

reply


This works for me in anarki, which is the community edition of arc:

  steve@steve-Satellite-L555D:~/anarki$ cat test.arc
  (prn "hello, world!")
  (quit)

  steve@steve-Satellite-L555D:~/anarki$ ./arc.sh test.arc > test.out

  steve@steve-Satellite-L555D:~/anarki$ cat test.out
  hello, world!

  steve@steve-Satellite-L555D:~/anarki$ 
Not sure how to do pass an file name to arc itself.

reply

4 points by akkartik 5 days ago | link

You're almost there. To pass in to Arc a filename argument to write to, you'd say this:

  $ cat test.arc
  (tofile (argv 1)
    (prn "hello, world!"))
(The quit is unnecessary since Arc will automatically quit after running all commands in batch mode.)

  $ ./arc.sh test.arc test.out
  $ cat test.out
  hello, world!
argv is a list containing commandline arguments, and tofile redirects prn to some given filename.

reply


Nice article.

Recursion has been one of those things which made my mind bend or expand. I can't imagine what it would normally take for a 12-year old to learn this abstract concept.

What again was your motivation for Mu?

Steve

reply

3 points by akkartik 8 days ago | link

Finding better ways to write code that let newcomers make sense of them faster. More details: http://akkartik.name/about

The teaching fits into this in two ways:

a) It seems like a more ambitious test. If I can make codebases easier for non-programmers or inexperienced programmers to understand, then experienced ones should hopefully be easy.

b) It's a way to get feedback. It's hard to find experienced programmers willing to try out a strange new way of writing code that isn't going to be useful in real products for a very long time. Without this feedback I'd be likely to burn out long before I can fully validate or invalidate my hypothesis. But at least for me, teaching is extremely rewarding/addictive.

Oh, there's a third way: since I get paid for my teaching, there's the distant possibility that I might be able to scale up the teaching to fund my research so that I can work on it full-time.

reply

3 points by jsgrahamus 8 days ago | link

Love teaching myself.

BTW, this HN link has some traffic: https://news.ycombinator.com/item?id=12501763

reply

1 point by akkartik 8 days ago | link

Thanks! I remember seeing it yesterday at 1 point and assuming it was done. Didn't notice when people started upvoting it. Oh well, probably too late now.

reply

3 points by jsgrahamus 9 days ago | link | parent | on: Creating a maze game

Thanks so much, guys.

Steve

reply

2 points by jsgrahamus 130 days ago | link | parent | on: A convenience layer over setforms

This turned out to be a LOT more difficult than I imagined.

Thanks so much.

-----

1 point by akkartik 130 days ago | link

Well, it was also doable with existing defset, but rocketnia saw something a bit messy and decided to clean it up in the process :) "Done, and gets things smart." (http://steve-yegge.blogspot.com/2008/06/done-and-gets-things...)

-----

2 points by jsgrahamus 134 days ago | link | parent | on: Lisp/C: lisp-flavored C

Someone has been busy.

-----

2 points by jsgrahamus 137 days ago | link | parent | on: Passing values up the line

Here is a related post: http://arclanguage.org/item?id=4370

-----

2 points by jsgrahamus 136 days ago | link

Here is a version from the linked post altered to take any size n. Can you see the cause of the error?

  (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 queens2 (max size stack)
    (if (is size max)
      (and (prall rev.stack "[ ") (prn " ]"))
      (for rank 1 max
        (push rank stack)
        (if (valid? stack)
            (queens2 max (+ size 1) stack))
        (pop stack))))

  (def queens (max)
     (with (size 0 stack nil)
        (queens2 max size stack)))

  arc> (queens 4)
  Error: "_R: undefined;\n cannot reference undefined identifier"
  arc>

-----

3 points by rocketnia 136 days ago | link

Whenever you see an error message complain about an undefined identifier named "_R", that's because of a long-standing issue with the Racket reader in Windows terminals. If you paste multiple lines into the terminal, what you paste needs to have a blank line at the end already or else Racket will think it sees an R somewhere in the middle of your code.

It's not your fault. It's a bummer to have to work around this.

-----

2 points by akkartik 136 days ago | link

BTW, you can always simplify (if <expression> nil t) to just (no <expression>).

Also, what's that i variable doing in valid?? I don't understand how valid? works..

You _really_ don't want to be making pass-by-reference changes like incrementing i inside some, since there's no guarantee about the order in which it'll run. If you want imperative updates, just use an explicit loop like each.

-----

1 point by akkartik 136 days ago | link

Hmm, that works for me on both Anarki and Arc 3.1. Are you running on Windows or something like that?

-----

1 point by akkartik 136 days ago | link

Ah, thanks! Lots to learn there.

-----

2 points by jsgrahamus 137 days ago | link | parent | on: Passing values up the line

Wow, that was quick: Time and lines of code.

Can you explain how it works?

I believe len.queens is (len queens).

What is:

  - (n (o queens))
  - queens.0.0
  - col
  - curr
  - some
  - (no [ is this the same as (~?]
When I ran it, I got

  arc> (nqueens 4)
  ((3 2) (2 0) (1 3) (0 1))
  ((3 1) (2 3) (1 0) (0 2))
  nil
  arc>
Is this in the form of ((col row) (col row) (col row) (col row))?

Thanks so much.

Steve

-----

1 point by akkartik 137 days ago | link

Yeah, I should have explained more. I'd planned the results to be in the form:

  ((row col) (row col) (row col) ...)
Your version works just as well :) but the variable names might make a little more sense this way.

a) (o queens) means that queens is an optional argument. If I don't pass in a value it's nil by default. I could also have given it an explicit default by saying (o queens 42). You can read more about this in the tutorial: http://www.arclanguage.org/tut.txt. Worth a reread if it's been a while.

b) queens.0.0 expands to ((queens 0) 0). Which is the same as (car (car queens)). Just a quick way to pull out the first row, the row of the most recently added queen (since I'm adding queens on the left using cons).

c) col is just a variable name for the column in the above representation of queens. But perhaps you were asking about up. Try this out at your Anarki prompt:

  arc> (help up)  ; only in Anarki
  arc> (up col 0 8 (prn col))
d) some takes a predicate (function) and a list, and returns true if any of the elements of the list is satisfied by the predicate (function returns true). Check out (help some), as well as the tutorial above. One twist is that you can pass in any number/character/boolean as a predicate, and it's as if you're comparing with it. So I'm asking "have we already seen this column?" in this line:

  (some curr-column (map [_ 1] rest))
e) Yes, no is like ~ though not quite the same. It's just simple boolean negation. (no nil) is t, no on anything else is nil. ~ (complement) is slightly different, it operates on functions and makes them return their negation. So this relation always holds:

   (no f.x) <=> (~f x)
I could have written (no conflicts.new-queens) as (~conflicts new-queens).

Thanks for asking!

-----

2 points by jsgrahamus 136 days ago | link

Thanks. Quite the learning experience for me.

-----

1 point by akkartik 136 days ago | link

Oh, I missed a question.

curr in conflicts contains the first or most recently added queen. So in this line I'm 'unpacking' the list of queens into the first and the rest.

  (let (curr . rest)  queens
    ..)
Try it out for yourself at the arc prompt. Compare these two:

  (let (a b) '(1 2 3) b)
  (let (a . b) '(1 2 3) b)

-----

More