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

implemented stack and queue in Go #909

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

henrikac
Copy link
Contributor

@henrikac henrikac commented Nov 1, 2021

This PR implements stack and queue in Go.

Note: code/go/stack-queue.goalso includes a func main where all the tests are written but I'm not sure where to include these (or if they are even required?)

Copy link
Contributor

@depate depate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

I like the use of the empty interface to make it more general.

One could think about commenting that behind the declaration to make it clear to beginners what interface{} means in this context, but maybe Leios wants to decide here.

Note: code/go/stack-queue.goalso includes a func main where all the tests are written but I'm not sure where to include these (or if they are even required?)

The code is able to run with go run stack-queue.go on its own that way, that's enough. It doesn't need to be embedded somewhere. One could move the "test code" into a separate function and call it in main() that's how it's sometimes done, e.g. Monte Carlo and others. But that's not a must either, I think.

@henrikac
Copy link
Contributor Author

henrikac commented Nov 2, 2021

One could think about commenting that behind the declaration to make it clear to beginners what interface{} means in this context

I'm all for making comments in the code if there is some part of an algorithm that can be difficult to understand but I am not a fan of making comments describing language syntax, e.g. what T is in Array<T> in Java.

@Amaras Amaras added Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) lang: go Go programming language labels Nov 3, 2021
@Amaras
Copy link
Member

Amaras commented Nov 3, 2021

The code is able to run with go run stack-queue.go on its own that way, that's enough. It doesn't need to be embedded somewhere.

We want to produce executables (as much as possible for all compiled languages) with the build system in construction, so I am not sure this point is valid right now.

@leios
Copy link
Member

leios commented Nov 3, 2021

@Amaras Does this PR conflict with the build system?

@Amaras
Copy link
Member

Amaras commented Nov 3, 2021

We haven't implemented the Go build system yet, but we need to think about the future.
It doesn't conflict with anything yet, though

@henrikac
Copy link
Contributor Author

henrikac commented Nov 8, 2021

@Amaras do I need to make any changes before this can get merged?

@Amaras
Copy link
Member

Amaras commented Nov 8, 2021

If you can compile it down to a runnable executable, it's good for me

@henrikac
Copy link
Contributor Author

henrikac commented Nov 8, 2021

go run stack-queue.go should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) lang: go Go programming language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants