Arc Forumnew | comments | leaders | submit | rincewind's commentslogin
1 point by rincewind 6096 days ago | link | parent | on: Load stops after nil

the old behaviour of whiler can the be achieved by writing

  (whiler var (snarfdata) [in var stopval nil]
     .. body)
or keeping the old whiler macro as whiler-old.

-----

1 point by rincewind 6114 days ago | link | parent | on: Struquine in Lisp (and Arc)

the difference between this and annotate is that this lets you write one quote less, compare:

   >(point 1 2)
   (point 1 2)
and

   >'#3(tagged point (1 2))
   #3(tagged point (1 2))

-----

2 points by rntz 6113 days ago | link

As far as I'm concerned, this is a bug/misfeature in Arc. Objects should always evaluate to themselves unless they're symbols or lists.

-----

1 point by rincewind 6120 days ago | link | parent | on: Alists vs table

the lookup time in alists is O(n). What about proto-tables? Is the key hashed again for lookup in every prototype?

-----

1 point by almkglor 6119 days ago | link

O(M) where M is the depth of the find, or the nested prototype depth if it's not found.

Yes, the key is rehashed.

But really, the point is that proto-tables are quite a bit easier to use: you still retain the table lookup syntax tb.key

-----

8 points by rincewind 6123 days ago | link | parent | on: Improve this function?

  (def rec-avg (lst)
     (if acons.lst
         (/ (apply + (map rec-avg lst)) len.lst)
         lst))

-----

1 point by rincewind 6126 days ago | link | parent | on: Help needed with macro

this only works for integer weightings

  (mac biased-choice choices
     (cons 'rand-choice (apply join (map [n-of car._ cadr._] pair.choices))))

  (def biased-choice choices
     (random-elt (apply join (map [n-of car._ cadr._] pair.choices))))
the second evaluates all of its arguments, which may or may not be what you want

-----

1 point by rincewind 6126 days ago | link

this works for fractional weightings also

  (def reducecollect (sum list start)
    (if acons.list
        (let csum (sum start car.list)
            (cons csum (reducecollect sum cdr.list csum)))))

  (def zip args
   (when (all acons args) 
      (cons (map car args) (apply zip (map cdr args)))))

  (mac biased-choice choices
   (with (ranges (reducecollect + (map car pair.choices) 0)
          items (map cadr pair.choices)
          random (uniq))
          `(let ,random (* (rand) ,last.ranges)
               (if ,@(apply join (zip (map [list '< random _] ranges) items))))))

-----

3 points by rincewind 6121 days ago | link

zip (like that in python) can be written shorter with map

  (def zip args (apply map list args))

-----

1 point by skenney26 6121 days ago | link

And here's a better definition of unzip:

  (def unzip (xs (o n 2))
    (apply map list (tuples xs n)))

  arc> (unzip '(a b c d e f) 3)
  ((a d) (b e) (c f))

-----

1 point by tokipin 6126 days ago | link

you can multiply by 10^n to get n-digit decimal precision

-----


I think this is the problem.

But running your webserver as root is a huge security risk. If your app is ever exploited, your whole system will be compromised.

try this instead and run your server on port 8080 http://en.wikipedia.org/wiki/Iptables#Redirection_example

-----

1 point by drcode 6126 days ago | link

I agree it's a security risk- Trying "sudo" would be a way to diagnose the problem but not a permanent solution.

-----


Arc2Parrot?

-----

3 points by rincewind 6135 days ago | link | parent | on: Has the leaders threshhold changed?

Please put links to the rss and lists operators at the bottom of the front page like on hacker news.

-----

2 points by rincewind 6146 days ago | link | parent | on: Poll: Destructive operations naming

what about d-join or join/d?

-----

2 points by stefano 6145 days ago | link

Added!

-----

2 points by rincewind 6150 days ago | link | parent | on: Io-like Objects

see also:

http://arclanguage.org/item?id=7462

http://arclanguage.org/item?id=7365

http://arclanguage.org/item?id=7530

-----

More