#Help with program

103 messages · Page 1 of 1 (latest)

vague lava
#

I believe your not putting in a second argument for your function

#

pseudo stuff:
x = Readfile(data)
y = save_data(x)
conclusie(rank_buildings(y), gebouw_namen, nums)

#

this is how you are currently having ur function call acting as

#

your only supplying the heights paramater but not the second names param

#

@median wedge

median wedge
#

ooh

vague lava
#

yep

median wedge
#

y = save_data(x) is not possible

vague lava
#

well I only did pseudo code

#

to show you ur function calls

median wedge
#

i still dont get how to fix tthis

vague lava
#

and what ur passing in as arguments

median wedge
#

conclusie(rank_buildings(save_data(data)),gebouw_namen,nums)

vague lava
#

okay

median wedge
#

is what i have

#

it contains all the arguments needed right

vague lava
#

oh let me see

#

oh facepalm

#

i did not look at the save_data function

#

give me a minute

median wedge
#

could you come up with something?

#

I think my code is abit messy

runic ingot
#

the error come from call to conclusie

median wedge
#

but what am i doing wrong

#

i filled in all the arguments

runic ingot
#

this wont work

func main() {
    f(x(), 9)
}

func f(_, _, _ int) {}
func x() (int, int) {
    return 0, 0
}
#

this would

func main() {
    f(x())
}

func f(_, _ int) {}
func x() (int, int) {
    return 0, 0
}
median wedge
#

and where does the 9 go

vague lava
#

ah so it seems like it has to have the exact amount of params to put in a multi-return value

#

so is his only avenue is to call it and put them into seperate variables and then call concluse?

median wedge
#

but im still confused on what i did wrong and how i can fix it

vague lava
#
    var z, x = save_data(Readfile(data))
    var g, y = rank_buildings(z, x)
    conclusie(g, y, gebouw_namen, nums)
#

in my testing this would work

#

(obviously bad code lol)

median wedge
#

why bad code?

runic ingot
# median wedge and where does the 9 go

you cant, x() is single expression, so its treated as single argument
just from f(x(), 9), you cant tell if x return multiple value and f accept three parameters.

vague lava
#

cuz variable naming and i broke it up to a point where it didint need to be

#
    var z, x = rank_buildings(save_data(Readfile(data)))
    conclusie(z, x, gebouw_namen, nums)
#

this should work too i think

median wedge
median wedge
vague lava
median wedge
#

oh oh

median wedge
#

but how can i make this code better

vague lava
#

ReadFile is expecting a filename string

median wedge
#

because you're saying its bad code

vague lava
#

uh

#

no what i wrote was bad

median wedge
vague lava
#

im still a newbie with go too

median wedge
#

ooh

#

yeah my plan was to also split the result of rank_buildings in 2, but i didnt know how

#

apperantly its just var x,y

vague lava
#

i don't think theres really way of getting around it unless u make ur functions specifically have the arguments amount u want.. but i mean just putting the values into varaibles should do the job

#

yeah

#

pretty much

median wedge
#

awesome

#

thanks alot man

#

both of you btw

#

really appreciate it ❤️

vague lava
#

np, boku found the issue p much lmao

median wedge
#

well, still appreciate it 😉

vague lava
#

whats that?

median wedge
#

?

#

variadic

vague lava
#

ahh

#

this is in javascript

#

so

#

i think he means basically

#

instead of ```go
func conclusie(hoogste_int int, hoogste_string string, names []string, heights []int) {

#

you do

func conclusie(hoogste_int int, hoogste_string string, other ...string) {
vague lava
#

but uh

#

im not sure how that works

#

with giving two splices as seperate args

#

if it like joins them or something

median wedge
#

hmm

#

@runic ingot is this right?

#

well, i guess he's afk

#

imma go look into it

#

again, thanks alot!

vague lava
#

np but im am curious how u would do this with the way boku suggested

median wedge
#

well, i guess we must wait for a reply ;p

vague lava
#

yeah true lol

#

it is a []int and a []string

#

so idk how u make a variadic type for both of those

#

I did get it working with any

#

but im not sure if youll have type issues in the future

median wedge
#

oh nice!

#

could you send it?

vague lava
#

oh wait

#

nvm

#

x.x

median wedge
#

F

vague lava
#

I attempted this

#

but got the same error

#

lol

runic ingot
#

nah, it does not work. i must have mistaken for somethig similar.

#

i wrote it on sunday, that probably why. coding in sunday is bad.