News for hackers. Stuff that matters.
Re:Show HN: Bel by excessive on Saturday October 12, 2019 @05:52PM (#21236624)
This one seems backwards to me:

    (2 '(a b c))
In addition to being data structures, I like to think of lists/arrays as functions which map integers to the contents. This nicely generalizes to hash tables / associative arrays, and then further to actual functions. If that's all reasonable, then

    ('(a b c) 2)
is the right order for application.

However, maybe pg is just thinking of 2 as a shorthand for cadr or similar.

Re:Show HN: Bel by pg on Sunday October 13, 2019 @03:42AM (#21239042)
Initially I would have preferred that. I did it that way in Arc. But since functions are lists in Bel, I couldn't do that, or you wouldn't be able to call a function on a number.

As often happened with things I was forced into, though, I not only got used to putting numbers first but started to prefer it. It means for example you can compose them with other callable things.

Re:Show HN: Bel by e12e on Sunday October 13, 2019 @07:18AM (#21239792)
Am I reading that right, that:

  (2 '(a b c))
Is equivalent to:

  (second '(a b c))
And that would work for strings as well:

  (5 "Hello, world!")
  > "o"
Which in turn means 'car and' 1 are equivalent? (probably means 'car should be thrown out, because surely '1 is clearer?

Ed: and with some notation to differenciate "element at N" and "tail behind N" you could get even more mileage out of integers? And then to generalize to lists of lists to reference elements and sub-sections (sub dimensions, like cubes) of matrices?

Not sure what would be nice, perhaps star or ellipsis?

  (1... '(a b c))
  >'(b c)

  ('(1..) '(0..2)
    '(
      (a b c)
      (d e f))
  >'(
    (b c)
    (d f))
Or something?
Re:Show HN: Bel by pg on Monday October 14, 2019 @06:51AM (#21246823)
It would not be clearer to use 1 instead of car when you were using a pair to represent a tree, rather than a list, and you were traversing the left and right branches using car and cdr.
Re:Show HN: Bel by e12e on Monday October 14, 2019 @09:09AM (#21247825)
Yes, I suppose that's something I've never grown quite used to with lisp - that it's lists (as a special form of "leaning" trees) and trees - not arrays and matrices.

I suppose even proper lists are incidental - it's really all about trees (and also parse trees).

Re:Show HN: Bel by andreareina on Sunday October 13, 2019 @02:50AM (#21238816)
It seems to be borrowing from clojure, in which both (field container) and (container field) do the same thing.