Difference between revisions of "Loop"
Jump to navigation
Jump to search
↑ http://www.golangpatterns.info/concurrency/parallel-for-loop
(Created page with " == Infinite loop == go <pre> sum := 0 for { sum++ // repeated forever fmt.Println(sum) } <pre>") |
|||
(9 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
== Infinite loop == | == Infinite loop == | ||
− | [[go]] | + | === [[go]] === |
<pre> | <pre> | ||
− | sum := 0 | + | package main |
− | for { | + | import "fmt" |
− | sum++ | + | |
+ | func main() { | ||
+ | sum := 0 | ||
+ | for { | ||
+ | sum++ | ||
fmt.Println(sum) | fmt.Println(sum) | ||
+ | } | ||
} | } | ||
+ | </pre> | ||
+ | |||
+ | Go do not support parallel for-loops , deprecated Sun's [[Fortress]] was support it. But they are easy to implement using [[goroutines]].<ref>http://www.golangpatterns.info/concurrency/parallel-for-loop</ref> | ||
+ | |||
+ | |||
+ | === [[Bash]] === | ||
<pre> | <pre> | ||
+ | #!/bin/bash | ||
+ | while true; do | ||
+ | ((var++)) | ||
+ | echo $var | ||
+ | done | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | == Related terms == | ||
+ | * <code>[[for]]</code> | ||
+ | * <code>[[/dev/loop]]#</code> | ||
+ | |||
+ | == See also == | ||
+ | * {{programming}} | ||
+ | |||
+ | [[Category:Programming]] |
Latest revision as of 06:54, 3 March 2021
Infinite loop[edit]
go[edit]
package main import "fmt" func main() { sum := 0 for { sum++ fmt.Println(sum) } }
Go do not support parallel for-loops , deprecated Sun's Fortress was support it. But they are easy to implement using goroutines.[1]
Bash[edit]
#!/bin/bash while true; do ((var++)) echo $var done
Related terms[edit]
See also[edit]
- Programming: C, Python,
go
,loop
,while
,for
,if
,variable
, Error handling, Regex, Function, IDE, await, R (programming language), XACML, Type, Class inheritance, Methods, Scheme, Array, Deserialization
Advertising: