Imperative Loops (for & while) in Reason

Nik Graf
InstructorNik Graf
Share this video with your friends

Social Share Links

Send Tweet
Published 6 years ago
Updated 5 years ago

In functional programming languages map, filter and reduce are often preferred over imperative loops. As stated in the official Reason docs the language creates don't have a preference on whether you should use a loop over these function.

In Reason we have for as well as while available.

Instructor: [00:00] We can use for loops to iterate from the starting value up to the ending value. The ending value is included.

[00:14] Keep in mind, though, it must be a valid range going from a lower to a higher integer. Otherwise, it won't go through any of these items. In order to make the loop count in the opposite direction, we can replace to with down-to.

[00:32] In addition, we have while loops at our disposal. They loop as long as the test condition inside the parentheses is true.

[00:39] [silence]

egghead
egghead
~ 28 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today