Skip to main content
deleted 8 characters in body
Source Link
sergiol
  • 4.2k
  • 1
  • 17
  • 37

If you are handling a list with an operation that syntactically is interleaving between each element, sometimes you can join elements to do a specific operation, instead of traversing it.

On https://codegolf.stackexchange.com/a/127042/29325 there is an example:

puts \n[expr [join [split [read stdin]]stdin] +]]

It read stdin gives 23 214 52 then split will give the list {23 214 52}. After, [join {23 214 52} +] will return the string 23+214+52. Finally expr 23+214+52 does the job of summing

If you are handling a list with an operation that syntactically is interleaving between each element, sometimes you can join elements to do a specific operation, instead of traversing it.

On https://codegolf.stackexchange.com/a/127042/29325 there is an example:

puts \n[expr [join [split [read stdin]] +]]

It read stdin gives 23 214 52 then split will give the list {23 214 52}. After, [join {23 214 52} +] will return the string 23+214+52. Finally expr 23+214+52 does the job of summing

If you are handling a list with an operation that syntactically is interleaving between each element, sometimes you can join elements to do a specific operation, instead of traversing it.

On https://codegolf.stackexchange.com/a/127042/29325 there is an example:

puts \n[expr [join [read stdin] +]]

It read stdin gives 23 214 52 then split will give the list {23 214 52}. After, [join {23 214 52} +] will return the string 23+214+52. Finally expr 23+214+52 does the job of summing

Source Link
sergiol
  • 4.2k
  • 1
  • 17
  • 37

If you are handling a list with an operation that syntactically is interleaving between each element, sometimes you can join elements to do a specific operation, instead of traversing it.

On https://codegolf.stackexchange.com/a/127042/29325 there is an example:

puts \n[expr [join [split [read stdin]] +]]

It read stdin gives 23 214 52 then split will give the list {23 214 52}. After, [join {23 214 52} +] will return the string 23+214+52. Finally expr 23+214+52 does the job of summing