Loading…
![]() Translation changed |
|
![]() Translation added |
|
![]() String updated in the repository |
|
Loading…
![]() Translation changed |
|
![]() Translation added |
|
![]() String updated in the repository |
|
Also, there's a safer kind of loop, [code]for[/code] loops, which we'll look at in the next lesson.
Yet, [code]while[/code] loops have important intermediate to advanced-level uses, so you at least need to know they exist and how to use them.
We use [code]while[/code] loops every time we need to loop an unknown number of times.
For example, games run in a loop that typically generates sixty images per second until the user closes the game. This is possible thanks to [code]while[/code] loops.
There are other good uses for [code]while[/code] loops:
- Reading and processing a file, like a text document, line by line.
- Processing a constant stream of data, like someone recording audio with a microphone.
- Reading code and converting it into instructions the computer understands.
- Various intermediate to advanced-level algorithms, like finding paths around a map for AI.
Ayrıca, bir sonraki derste inceleyeceğimiz gibi, [
/code]for[/code] döngüleri gibi daha güvenli bir döngü türü de var.Yine de, [code]while[/code] döngülerinin orta ve ileri düzeyde önemli kullanımları vardır, bu nedenle en azından var olduklarını ve nasıl kullanılacaklarını bilmen gerekir.
Bilinmeyen bir sayıda yinelemeye ihtiyaç duyduğumuz her seferde [code]while[/code] döngülerini kullanırız.
Örneğin oyunlar, kullanıcı oyunu kapatana kadar genellikle saniyede altmış görüntü üreten bir döngü içinde çalışır. Bunu yapmak, [code]while[/code] döngüleri sayesinde mümkündür.
[code]while[/code] döngülerinin başka iyi kullanımları da var:
- Metin belgesi gibi bir dosya
yının, satır satır okuyup işlemek.- Mikrofonla ses kaydı yapan biri gibi, sürekli bir veri akışını işlemek.
- Bir kodu okumak ve içindekileri bilgisayarın anlayacağı talimatlara dönüştürmek.
- Yapay zeka için bir haritanın etrafındaki yolları bulmak gibi çeşitli orta ve ileri düzey algoritmalar.