Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixed operation in 'list-insert' #361

Open
Affonso-Gui opened this issue Jan 18, 2019 · 5 comments
Open

Mixed operation in 'list-insert' #361

Affonso-Gui opened this issue Jan 18, 2019 · 5 comments

Comments

@Affonso-Gui
Copy link
Member

In list-insert, we have non-destructive operation for null lists or zero position and destructive operation for other cases.

https://github.com/euslisp/EusLisp/blob/master/lisp/l/common.l#L369-L377

Shouldn't these be unified as destructive operation?

@Hunter11zolomon
Copy link

Hunter11zolomon commented Mar 24, 2019

Shouldn't these be unified as destructive operation?

Can you please elaborate what you mean by unifying the destructive operations?

@Affonso-Gui
Copy link
Member Author

Sorry, that was not clear enough. I mean that list-insert should be destructive for null lists and zero index as well. That is, what now looks like:

(setq lst nil)
;; nil
(list-insert 1 0 lst)
;; (1)
lst
;; nil       ;Not Destructive
(setq lst (list 1 2))
;; (1 2)
(list-insert 3 2 lst)
;; (1 2 3)
lst
;; (1 2 3)   ;Destructive
(list-insert 0 0 lst)
;; (0 1 2 3)
lst
;; (1 2 3)   ;Not Destructive

Should be:

(setq lst nil)
;; nil
(list-insert 1 0 lst)
;; (1)
lst
;; (1)     ;Destructive
(setq lst (list 1 2))
;; (1 2)
(list-insert 3 2 lst)
;; (1 2 3)
lst
;; (1 2 3)   ;Destructive
(list-insert 0 0 lst)
;; (0 1 2 3)
lst
;; (0 1 2 3)   ;Destructive

@Hunter11zolomon
Copy link

This looks right to me.
I will try to make a pull request.

@Affonso-Gui
Copy link
Member Author

Thanks, your help is appreciated.

In case you have not found it yet, the function definition is in https://github.com/euslisp/EusLisp/blob/master/lisp/l/common.l#L369-L377 .

@Hunter11zolomon
Copy link

made a pull request
#369

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants