Hy,

I'm trying to do the smart challenge second task. However i'm currently trying to understand the part about messages. If need to send a message I need to know the target address. How am I supposed to know it ? I someone could give me a hint this would be awsome

Dec 6, 2022, 11:56 AM
Or is it store inside msg and I need to modify msg such that the value is correct ?
Dec 6, 2022, 11:57 AM
In the statement it says you can send the message to any address.
Your own address or any other should do fine
Dec 6, 2022, 12:05 PM
As an internal or external message ? Because in Ton VM documentation I see 2 types of messages (0 or 11)
Dec 6, 2022, 12:08 PM
it should be internal message
Dec 6, 2022, 12:13 PM
Someone else also managed to solve something
The intermediate place for 0 point is (number of people with score > 0) + 1
Can we write mutually recursive functions in FunC ?
When I'm trying to do this I get a compilation error saying the second function is not defined in the body of the first
Dec 6, 2022, 1:45 PM
Oh makes sense
Can I right a function f(x, y) that receives for example two variables x and y (that exist in the scope that f is called) and change their values in the whole program?

If you're familiar with c++, I need such function:
void f(int& x, int& y){
x+=1;
y+=1;
}
Dec 6, 2022, 2:01 PM
you can’t pass primitive by reference
but you can define global variables
Dec 6, 2022, 2:02 PM
what does this error mean?
lvalue expression constructor is 9
fatal: cannot compile lvalue expression with unknown constructor

edit:
sorry, didn't mean to reply
Dec 6, 2022, 2:29 PM
you are probably trying to modify a global variable not through assignment but by something like global_var~modifying_function();

if this is the case, either change your code not to use this global variable, or do this modification using a temporary variable
Dec 6, 2022, 2:35 PM
for the first task, as far as I know tpush has limit of 255 elements, and I think in one of the cases my algorithm face this limit, any suggestion or alternative to use?
Dec 6, 2022, 2:38 PM
nested tuples
Dec 6, 2022, 2:38 PM
I want to have a dictionary and I don't want to pass it around to functions, I definitely want to change it's content if necessary, so you're saying I must use local variables?
Also if I can't change its content, why is it called a global "variable"?😂
Dec 6, 2022, 2:40 PM
well I faced exactly that error 5 minutes ago and couldn't figure out a way to use global vars with modifying functions
I, too, didn't want to pass it around
you can change the content like so global_var = ...; and probably with operator assignemnts like +=, *= etc but it seems that right now you can't use modifying functions on global vars
my guess as to why would probably be because global variables are not on stack usually, they are put onto the stack with GETGLOB and are set back into globals using SETGLOB, and I guess func can't figure out that it needs to GETGLOB the global before modifying function and then SETGLOB it back
but idk what I'm talking about, could be something way different
Dec 6, 2022, 2:45 PM
global cell a;
() main(){
a = new_dict();
int x = 5;
cell msg = begin_cell().store_uint(0x10, 6).end_cell();
a = udict_set_ref(a, 32, x, msg);
}

that one compiles fine, but for some reason, this one won't:

global cell a;
() main(){
a = new_dict();
int x = 5;
cell msg = begin_cell().store_uint(0x10, 6).end_cell();
a~udict_set_ref(32, x, msg);
}
Anyone know the difference?
Dec 6, 2022, 2:54 PM
I actually tried the first one but when there's a multiple assignment using a global var like (global, local1, local2) = ... then it doesn't work too
maybe the second one translates into (a) = udict_set_ref which involves tensor unpacking too and maybe that causes the issue
Dec 6, 2022, 2:55 PM
I saw a ~debug that dumps the value. Is there a ~print that dumps a slice by interpreting it as a string ?
Dec 6, 2022, 3:20 PM
there's ~strdump
Dec 6, 2022, 3:23 PM
Do you know any good documentation about how to handle strings in func?
(How to read them, how they're represented, etc.)
Dec 6, 2022, 3:26 PM
Description of task3 contains a link to docs where you'll find that
Dec 6, 2022, 3:27 PM
I read that and understood nothing😂
I probably should first choose which string type to use (which I don't know yet), in order to be able to have random access to i'th character and also have it's size.
Also I don't know how to read and store this string from an internal message to my program.
Do you know any code examples?
Dec 6, 2022, 3:41 PM
so have you seen the Snake string type or not?
Dec 6, 2022, 3:42 PM
You mean like:
"Blah blah"s
?
?
Dec 6, 2022, 3:48 PM
well here is an example of a string representation from documentation
this one is a format used for "simple comment transfers" i.e. transfers of TON with just a string comment
root_cell("0x00000000" - 32 bit, "string" up to 123 bytes)
↳1st_ref("string continuation" up to 127 bytes)
↳1st_ref("string continuation" up to 127 bytes)
↳....
the 0x00000000 is the op which you don't need if you just want a string
it does not provide random access however, and really I don't know what you could do to get random string access - we don't really have arrays in func
unless your string is <=255 chars long, then you can parse it into a tuple and get chars using indices
another (ugly) solution would be a dictionary that contains keys as indices and chars as values
Dec 6, 2022, 3:48 PM

© 2024 Draquery.com All rights reserved.