Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "strconv"
- )
- type Vector []float64
- func NewVector(args ...float64) Vector {
- return args
- }
- func (v Vector) String() string {
- out := "("
- for i, e := range v {
- out += strconv.FormatFloat(e, 'f', -2, 64)
- if i < len(v)-1 {
- out += ", "
- }
- }
- out += ")"
- return out
- }
- func main() {
- v := NewVector(1, 2, 3, 4, 5)
- fmt.Println(v)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement