Arc Forumnew | comments | leaders | submitlogin
1 point by rocketnia 4552 days ago | link | parent

Since = is a macro, (map = ...) is not going to work.

This might do what you want:

  (listtab:map list '(x y z) '(1 2 3.14))
The result of map is ((x 1) (y 2) (z 3.14)), and listtab converts that to a table.

Arc's (a:b ...) syntax is short for (a (b ...)), in case that's confusing. :)

If you insist on using map and =, here's a way to do it:

  (let tbl (table)
    (map (fn (k v) (= tbl.k v))
      '(x y z)
      '(1 2 3.14))
    tbl)
The tbl.k syntax is short for (tbl k).

You might also be interested to know that (= tbl.k v) expands to (sref tbl v k).

---

"the fact we can't assign a value to x with a derivative of that expression - that expression being good in itself."

Yeah, it would be kinda nice if (= (eval 'x) 2) worked. It could expand to (eval `(assign x (',(fn () 2)))). In fact, the defset utility lets us add that behavior ourselves if we want it.



1 point by FredBrach 4552 days ago | link

>> In fact, the defset utility lets us add that behavior ourselves if we want it.

At this stage, I also can go back to C :)

Do you get what I mean? Arc, if I may, should be a language which is damn hard consistent at least on the basic concepts and which use kind of self generated strategy to reduce LOCs, not hard coded pseudo-concept like most languages.

Ok. I will maybe try to write an implementation by myself with C.

Hey thank you :)

-----

1 point by rocketnia 4548 days ago | link

"Arc, if I may, should be a language which is damn hard consistent at least on the basic concepts and which use kind of self generated strategy to reduce LOCs, not hard coded pseudo-concept like most languages."

You might be surprised to hear this, but many of us here like Arc for exactly this reason. It inherits its simplicity and conistency from Scheme.

However, Arc's main improvement upon Scheme is the fact that it uses some quirky abbreviations. These abbreviations do take the form of "hard coded pseudo-concepts."

I might have been wrong to inform you about these abbreviations when you were just starting to learn Arc. If you can, forget about (= ...) and (a:b ...) and stuff, and then see if you like the language any better. ;)

-----

1 point by FredBrach 4552 days ago | link

>> (let tbl (table) (map (fn (k v) (= tbl.k v)) '(x y z) '(1 2 3.14)) tbl)

Haha. just rewrite = as it should - the binding operation being an atomic operation. = should be

(fn (k v) (bind k v))

EDIT: oh ok it's assign not bind.

-----

1 point by FredBrach 4552 days ago | link

>> (listtab:map list '(x y z) '(1 2 3.14))

Pretty much better I agree.

-----