libera/#lisp - IRC Chatlog
Search
21:59:51
prokhor__
i think there is not one correct answer to that... everybody does as he is used to/suits him best...
22:00:51
Shark8
In some sense it *is* sweeping things under the rug (ie being unconcerned that the TASK *might* be compiled with only a single-core assuming compiler) and putting the onus on the compiler, but on the other hand it's (a) using high-level specification/construction, and (b) allowing the abstraction to be interpreted/realized in some other manner.
22:00:57
prokhor__
i have some vague top-level ideas of my implementations, but i also test them by thinking about specific low-level problems in those cases...
22:03:58
Shark8
prokhor__, (re: Top-down vs Bottom-up) -- I've talked with some programmers who really love Ada because you can do some nice things like Top-down design and bottom-up implementation (in this case by defining the packages, types, and [visible] subprograms [as stubs], getting a clean compile, then "backfilling" by implementing them).
7:28:59
rendar
can we say that apply internally checks the number of arguments that the functions accepts, and if its 2, and the list of params len > 2, it will act like a reduce
7:36:55
wasamasa
you can translate a function accepting several arguments to a function accepting one argument less
7:42:12
wasamasa
if you want to expose apply to the lisp interpreter, it's slightly bit more complicated
7:51:40
rendar
wasamasa, the problem with `return func(*func_args)` is it works when i call (+ 1 2), but it doesn't when i call (+ 1 2 3)
7:52:23
wasamasa
in scheme (+) returns 0, (+ 1) returns 1, (+ 1 2) returns 3 and (+ 1 2 3) returns 6
7:53:27
wasamasa
you need to implement + in terms of functools.reduce, not apply in terms of functools.reduce
7:54:22
wasamasa
no, you need to look at every individual function you need to implement and decide how
7:54:57
rendar
the point is that in lisp every 2-ary functions like +, -, / and so on, seem to take N args
7:55:27
rendar
a kind of minimal lisp just to insert commands in a system, minimal ability to create functions and macros
7:57:51
wasamasa
you still need to decide how basic arithmetic should behave and how a useful standard library looks like
9:17:31
rendar
also, there must be some internal mechanism that will map (- 1) to an unary not function, and (- 1 1) to 2-ary minus function..
9:19:46
wasamasa
but you might as well just have your minus function check for the number of arguments itself
9:27:37
pjb
(defun - (arg &rest args) (if (null args) (* -1 arg) (+ arg (* -1 (apply (function +) args)))))
9:32:16
sham1
(define - (case-lambda ((x) (negate x)) ((x . ys) (actually-subtract x (reduce + 0 ys)))))