Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

runtime: zip #127

Open
avelino opened this issue Feb 13, 2018 · 8 comments
Open

runtime: zip #127

avelino opened this issue Feb 13, 2018 · 8 comments

Comments

@avelino
Copy link
Member

avelino commented Feb 13, 2018

(zip (list 1 2 3) (list 4 5 6) (list 7 8 9)) ;;=> ((1 4 7) (2 5 8) (3 6 9))
(zip (list 1 2 3) (list 4 5 6))              ;;=> ((1 4) (2 5) (3 6))
@trumae
Copy link
Contributor

trumae commented Feb 13, 2018

In the lisp way the right is:
(zip '(1 2 3) '(4 5 6) '(7 8 9)) ;;=> ((1 4 7) (2 5 8) (3 6 9))
(zip '(1 2 3) '(4 5 6)) ;;=> ((1 4) (2 5) (3 6))

Or can be like Clojure:
(zip [1 2 3] [4 5 6] [7 8 9]) ;;=> [[1 4 7] [2 5 8] [3 6 9]]
(zip [1 2 3] [4 5 6]) ;;=> [[1 4] [2 5] [3 6]]

That is needed for the language decide when evaluate a parameter as a function call or as an simple data list. In your example: (1 2 3) is an list or the funcion "1" applied on parameters 2 and 3? And how does works an form like (get-data "sample 1" 300) used as an zip function parameter?

@trumae
Copy link
Contributor

trumae commented Feb 13, 2018

Another solution is always use an function as list constructor when an list is needed. Like:
(zip (list 1 2 3) (list 4 5 6) (list 7 8 9)) ;;=> ((1 4 7) (2 5 8) (3 6 9))
(zip (list 1 2 3) (list 4 5 6)) ;;=> ((1 4) (2 5) (3 6))

The "list" word/function can be replaced by "array".

@crgimenes
Copy link
Contributor

crgimenes commented Feb 13, 2018

About lists, if the first element is not a function or lambda we can assume that it is just a list.
Example:
((1 4 7) (2 5 8) (3 6 9)) it is a list of lists.
(print "test") it is a function with a parameter
(array (print "test")) or (list (print "test")) it is a list, function print is te element 0 anda the string "test" is the element 1
'(print "test") is the same as the previous... although I do not like this version
() and finally this is an empty list, if used in an if or for is the same as false.
I believe that in this way we leave the use of lists very simple and intuitive.

@trumae
Copy link
Contributor

trumae commented Feb 13, 2018

So it will be impossible to declare one list of functions or lambdas?

@avelino
Copy link
Member Author

avelino commented Feb 13, 2018

We will follow the same run of Go, array serves for both approach (Array and list)

@crgimenes
Copy link
Contributor

@trumae I do not know if I understood correctly, but to declare an array of functions just put the word "array" at the beginning.

@trumae
Copy link
Contributor

trumae commented Feb 14, 2018 via email

@avelino
Copy link
Member Author

avelino commented Feb 21, 2018

used list, update description

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants