You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Check the type of element inside the list for str.join() #2366
Actually, I am still not checking the type of element inside the list which should be str, I checked grammar for asr but didn't get anything on how to iterate over list expression as it must be a list of str expressions. ast is getting generated perfectly but, I don't know how can I map ast nodes to asr nodes.
I am still not able to iterate over the List_t ASR node
You need not iterate over the List_t. You can simply get the element type of the list (using the above shared approach) and check if the element type is a string or not.
The List already contains elements of the same type.
Activity
ubaidsk commentedon Oct 6, 2023
You can refer the following approach to get the List type:
lpython/src/lpython/semantics/python_ast_to_asr.cpp
Lines 1413 to 1415 in 37eca1a
Agent-Hellboy commentedon Oct 6, 2023
sure
Agent-Hellboy commentedon Oct 9, 2023
Hi @Shaikh-Ubaid, I am still not able to iterate over the
List_tASR node, I am not able to get any info ASR.asdlHow can I iterate over expr_t to get the list element?
here is expr_t
I guess expr can be expr = expr | list_of_expr right?
I am kinda confused, the example you shared is to check if the expression is list type or not.
ubaidsk commentedon Oct 9, 2023
You need not iterate over the
List_t. You can simply get the element type of the list (using the above shared approach) and check if the element type is a string or not.The List already contains elements of the same type.