Arc Forumnew | comments | leaders | submit | rincewind's commentslogin
1 point by rincewind 5612 days ago | link | parent | on: Search functionality for this forum?

http://af.searchyc.com/

-----

5 points by rincewind 5658 days ago | link | parent | on: Request for Bugs

http://www.arclanguage.org/item?id=7934

-----

1 point by pg 5646 days ago | link

Thanks; this is now fixed.

-----


how about you upload them to github? :-)

-----

1 point by CatDancer 5693 days ago | link

I'm using git and github as an experiment, wondering what the best way to share Arc patches might be. For myself, so far using git has felt like driving a tractor trailer to get a sandwich at the corner grocery store... big, powerful, can move an awesome amount of stuff, but clumsy... necessary when you have tens of thousands of lines of code, but when your language is high enough level that you don't need that many lines of code, is git actually useful? I don't know yet. In any case, I'm happy to get patches in any form that is convenient for the sender, whether by email, pastebin, or by github's "pull request" mechanism.

-----


  (or= value2 'wahoo)

-----

2 points by thaddeus 5732 days ago | link

That does it.... Thanks, T.

    (def the-example (value1 value2 value3 value4)
         (or= value1 'Results)
         (or= value2 'wahoo!)
         (or= value3 'ugh!)
         (or= value4 'omg!)
         (prn "Value1: " value1)
         (prn "Value2: " value2)
         (prn "Value3: " value3)
         (prn "Value4: " value4)
)

-----

3 points by absz 5731 days ago | link

You could also wrap your or= sequence in a macro:

  (mac defaults args
    `(do ,@(pair args (fn (var val) `(or= ,var ,val)))))
  
  (def the-example (value1 value2 value3 value4)
    (defaults value1 'Results
              value2 'wahoo!
              value3 'ugh!
              value4 'omg!)
    (prn "Value1: " value1)
    (prn "Value2: " value2)
    (prn "Value3: " value3)
    (prn "Value4: " value4))

-----

1 point by rincewind 5759 days ago | link | parent | on: Where are we going?

Have you thought about interop with Clojure?

-----

1 point by conanite 5759 days ago | link

Not yet :)

but theoretically you could host a bunch of languages in a single jvm instance - and have arc, clojure, jruby, jython, and javascript (via rhino) all calling each other in a big polyglotfest. Java 6 includes a scripting framework ( https://scripting.dev.java.net/ ) that standardises the way a jvm hosts a ScriptEngine. I haven't looked at this yet at all but it's on my todo list.

-----


What about using default paramters for optional args?

  (def todays-event ((o type) (o todays-thing nilfn))
     ...

-----


What do you want to do with these data structures exactly?

Something like this?

  (= names* 
    (obj person1 '("Jon" "Mid" "Dow")
         person2 '("Alex" "Morse" "Lstname") 
         person3 '("Jane" "Moodd" "Meow")))

  (def get-name-part (person part)
       ((names* person) ((obj first 0 middle 1 last 2) part)))

-----

1 point by thaddeus 5795 days ago | link

I've have to check the code at home, at work now.....

Essentially I'm taking a spreadsheet file (csv) with an arbitrary number of columns of data, reading in the headers so they can be output to the html table as headers then reading in the remainder to create rows in the html table.

also also letting users to pick and choose which columns of data they want by selecting header names.

I've pretty much got it all working, I'm just surprised the language wouldn't provide for passing in results of an iteration function cleanly. To have to create an extra function simply to strip out the nil ends up making the code readability poor..... I'm sure I will look at the code in 2 months, scratch my head and ask why I needed a second function.... of course by then I'll probably have found a better way :)

-----

1 point by rincewind 5795 days ago | link

  (def keep-cols (cols tabl) ;for one row
     (map [let nr -1 (keep [some (++ nr) cols] _)] tabl))

  (def get-cols (cols tabl) ;table with selected columns
      (withs ((head . rows) tabl
              colnrs (rem nil (map [pos _ head] cols))
              filtered-rows (keep-cols colnrs rows))
        (cons cols filtered-rows)))

  ;test
  (get-cols '(foo baz) '((foo bar baz) ;header
                         (bla bla spam)
                         (eggs ham bacon) 
                         (lorem ipsum test)))

-----

1 point by thaddeus 5794 days ago | link

That's much nicer code than mine :)

I'm going to step through some of the syntax; I haven't been using: map, [], or "." yet.

Thanks, T.

-----

1 point by rincewind 5832 days ago | link | parent | on: Brainstorm: syntax sugar for lambdas

let [... _ ...] mean (fn _ (... _ ...))

example usage:

  (reduce [-  (/ _.1 (* 2 _.0))] mylist)

-----

1 point by absz 5832 days ago | link

Unfortunately, this is then deoptimized for the most common one-argument case, where you have to write [... _.0 ...]. We could have [...] expand to (fn __ (let _ (car _) ...)), so that you would have

  (reduce [- (/ __.1 (* 2 __.0))] mylist)
but still have

  (map [+ _ (* _ _)] myotherlist)
. I still prefer the _1, _2, ... syntax, though---unsurprisingly, as I contributed that implementation (though not the idea) :)

-----

1 point by shader 5832 days ago | link

Actually, I do think the _1, _2 .. syntax makes the most sense, if you aren't wanting to name parameters. Though maybe (as was mentioned above) in some cases, the first three should be a b c, or x y z? I don't know how you would set that up to work well with what already exists though.

-----

1 point by rincewind 5833 days ago | link | parent | on: Brainstorm: syntax sugar for lambdas

I implemented something like the first one in my m-expression reader, "a -> b;" is translated into "(fn a b)". It could be used with cchooper's customisable reader, so you can still use s-exprs most of the time, like this:

  (map #m[a;b]-> 0 - b / 2 / a; my-list)
it would be read as

  (map (fn (a b) (- 0 (/ b 2 a))) my-list)

-----


Is it LL(1)?

-----

3 points by cchooper 5844 days ago | link

Only if you ignore symbols and numbers. Lisp symbols are not LL(1), e.g. 123456A is a valid symbol.

-----

More