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

K++ perhaps. I'm sort of making unjust fun of the language, but I seriously prefer ((())()()) to this.

  #import std
  #import nat
  
  #comment -[
  solves the general case of the 8 queens problem;
  invoke as queens -n, where n is a number > 3]-
  
  #executable <'par',''>
  #optimize+
  
  queens =
  
  %np+~command.options.&h.keyword.&iNC; -+
     ~&iNC+ file$[contents: --<''>+ %nLP*=; * '<'%='[ '+          ','%=', '+ '>'%=' ]']+ ~&rSSs+ nleq-<&l*rFlhthPXPSPS,
   ~&i&& ~&lNrNCXX; ~&rr->rl %tLnLtXLLWXMk+ ^/~&l ~&lrrhrSiF4E?/~&rrlPlCrtPX ~&r; ^|/~& ^|T\~& -+
      -<&l^|*DlrTS/~& ~&iiDlSzyCK9hlPNNXXtCS,
      ^jrX/~& ~&rZK20lrpblPOlrEkPK13lhPK2; ~&i&& nleq$-&lh+-,
   ^/~&NNXS+iota -<&l+ ~&plll2llr2lrPrNCCCCNXS*=irSxPSp+   ^H/block iota; *iiK0 ^/~& sum+-

-----

1 point by bOR_ 6426 days ago | link | parent | on: How is reddit making money?

from http://www.juxtaviews.com/2006/08/08/reddit-interview-social...

  There’s absolutely no advertising on reddit. Why and what would it take for us to begin seeing ads on reddit?

  AO: There’s absolutely no advertising on our front page, but our comments pages do have Federated Media ads. We heart FM.

Well, the no ads on the frontpage is no longer true, but I guess that one well-placed ad is better than a bunch of annoying floats / popover banners. Reddit has been making a profit for a while now.

-----

4 points by bOR_ 6433 days ago | link | parent | on: problem combining each with a list of tables

Thanks! This now works, and I'm learning :)

  ; makes a world matrix
  (def makeworld (x)
    (= world (n-of x (n-of x nil))) ; world of nil
    (= merged (n-of x (n-of x nil))) ; layer of movers
    nil)


  ; print out the world, imposing a list of critters
  ; on top of it. The list itself assumes that its entries
  ; are tables which have a symbol and a position field
  (def show (lst)
    ; copy world into merged
    (for y 0 (- (len world) 1)
      (for x 0 (- (len world) 1)
        (= ((merged y) x) ((world y) x))))
    ; superimpose critters
    (each c lst
      (= ((merged (car (c "pos"))) (cadr (c "pos"))) (c "symbol")))
    ; plot world
    (each row merged
      (each pos row (if (is pos nil) (pr #\. #\space) (pr pos #\space)))
      (prn)))

  (= creature (table))
  (= creature2 (table))
  (= creature3 (table))
  (= (creature "pos") '(1 3))
  (= (creature2 "pos") '(10 3))
  (= (creature3 "pos") '(8 8))
  (= (creature "symbol") #\$)
  (= (creature2 "symbol") #\@)
  (= (creature3 "symbol") #\#)
  (makeworld 15)

  arc> (show (list creature creature2 creature3))
  . . . . . . . . . . . . . . . 
  . . . $ . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . # . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . @ . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  nil

-----

2 points by cchooper 6432 days ago | link

Nice! Is that going to be a game or something?

-----

1 point by bOR_ 6402 days ago | link

http://wwww.bagofsouls.com

It's the start of a new project for me (and hopefully later on a postdoc position on the topic). The idea is to build some kind of smart animals in an artificial world, without having to design them, or run through countless of iterations with genetic algorithms to get one.

With a good basic structure, they should be able to get smart on their own ;).

-----

1 point by bOR_ 6462 days ago | link | parent | on: Poll: Where are you from ?

netherlands +1 :)

-----

3 points by bOR_ 6483 days ago | link | parent | on: Strings as lists, generic regexes

Tested for you (arc1):

  Use (quit) to quit, (tl) to return here after an interrupt.
  arc> (string '())
  ""
  arc> (is '() "")
  nil
  arc> (is nil "")
  nil
  arc>

-----

2 points by bOR_ 6490 days ago | link | parent | on: Cut and Index - Arc and Ruby Side By Side

A possibility (although not immediately intuitive) is a - modifier in front of a list that reverses it :

  (-s i)  "i'th item of s from the end"

  (cut -s 0 x)  "the last x items of s"

  (cut -s j x)  "The items from position i to the end minus the last j items"
The only trouble being that you get your answer in reverse ;).

-----

1 point by bOR_ 6491 days ago | link | parent | on: Access to MzScheme functions

Thanks. Needed that for (xdef 'sin sin)

-----

2 points by bOR_ 6491 days ago | link | parent | on: Shorter programs, fewer axioms

In ruby the lack of a ! at the end of a method isn't a guarantee that a function changes (caught me a few times by surprise). It is just used to distinguish between a state-changing version and nonstate-changing version. The reason for that was to limit the number of !! in your code.

  (+ counter 1)
would have to become

  (+! counter 1)

-----

2 points by lojic 6491 days ago | link

"In ruby the lack of a ! at the end of a method isn't a guarantee that a function changes"

Don't you have that backwards? Typically the ! suffix on a method name in Ruby indicates that the method modifies state.

Also, why would (+ counter 1) have to change to (+! counter 1) ? The former doesn't modify state, it simply returns the sum, right?

-----

1 point by bOR_ 6491 days ago | link

Ugh, as lojic pointed out (thanks for that :)), some sleep-deprived errors in this post. The more correct version:

  In ruby, the lack of a ! at the end of a method isn't a guarantee that a function doesn't modiefy state.
And you're right about (+ counter 1). Blindly remembered the example I got in the ruby forum when I was surprised that some method modified state without a warning !.

The correct example in arc would be this:

  (++ counter 1)
would have to become

  (++! counter 1)

-----

1 point by bOR_ 6494 days ago | link | parent | on: macro / function question

I've a function that binds a list of lists to to variable 'world', and a function that prints out this world.

  (def makeworld (x)
    (let z nil
      (repeat x (= z (cons nil z)))
      (repeat x (= z (map [cons nil _] z)))
    (= world z)))

  (def show ()
    (each x world
    (each y x
    (pr (if (is y nil) #\. y) #\space))
    (pr #\linefeed)))
The world can then be seeded with trees, or shrubs or monsters or whatever. Anyway, as the world is a list of lists, it functions as a two-dimensional array.

If in arc I want to access a point in this two-dimensional list / array, I need to enter ((world 0) 3), and the basic question was how to change arc (macrowise) to make (world 0 3) be equivalent to ((world 0) 3). I already worked around it by now.

To answer your question: you're assuming that there is a list called 'list', and in my initial example I described a function that took the name of the list as first argument.

-----

2 points by fallintothis 6493 days ago | link

The problem with multiple values being subsequent accesses is it would also interfere with a useful syntax (not actually in Arc, but I mean insofar as deciding which it should mean), and that's subsequence indexing. It's been discussed all over the place, e.g. http://arclanguage.org/item?id=449

With the assumption that one of them takes that syntax, what should be used for the other? How about (seq '(0 3 ...)) or (seq (0 3 ...))? It would similarly be fitting for any number of arguments, be they dimensions or indices, though I would vouch to use the list for n-dimensional indexing as the case of subsequences seems more common. Plus the use of a list distinguishes the one type of access from the other without having to go (...((seq 0) 3) ...).

Not that any of this helps your problem. Just something I noticed.

-----

1 point by kennytilton 6494 days ago | link

Oh, I get it. No, this is not something you can do with macrology because there is no room for a macro in your desired syntax (where you just want the list itself and the index values). As you say, if you'll make room for another token it can just be a function (which would be fun to generalize to N dimensions). As for making ((list (list 42)) 0 0) return 42, I think you need to is suggest it as a (very reasonable) enhancement to Arc.

-----

2 points by pg 6494 days ago | link

I don't understand exactly what this code is for, but I think you could write makeworld as

  (def makeworld (x)
    (= world (n-of x (n-of x nil))))

-----

2 points by bOR_ 6496 days ago | link | parent | on: core language thingies

simplicity. I want (and I think I've seen enough examples of code now to write a macro to do so).. I want to be able to say / think / write this:

  (if (calculation gives wanted result) (assign calculation to variable)).
saying / thinking / writing your version just puts the language in the way of what I want to write down.. and even though the difference is minimal, all these little kind of things can add up and obfuscate your code.

  (store calculation as variable
    (if (variable gives wanted result) (assign calculation to another variable))
General idea of the post was just to try and find bits and pieces where the language can be smoothened.

-----

More