Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amit Maor #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ project/target
.classpath
.project
target
/bin/
9 changes: 9 additions & 0 deletions src/main/scala/internal/ForLoop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ object ForLoop extends App {

// define the new control-flow structure here

def for_loop(startVal: =>Unit) (cond: =>Boolean) (inc: =>Unit) (body: =>Unit) {
startVal
if (cond) {
body
inc
for_loop(Nil)(cond)(inc)(body)
}
}

var i = 0;
for_loop(i = 0)(i < 10)(i += 2) {
println(i);
Expand Down
8 changes: 7 additions & 1 deletion src/main/scala/internal/LoopUntil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ object LoopUntil extends App {

// define the new control-flow structure here

var i = 0
def loop_until(cond: =>Boolean) (body: =>Unit) :Unit = {
if (!cond) {
body
loop_until(cond)(body)
}
}

var i = 0
loop_until (i > 9) {
if ( (i % 2) == 0 )
println(i)
Expand Down
12 changes: 11 additions & 1 deletion src/main/scala/internal/RepeatUntil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ package internal
object RepeatUntil extends App {

// define the new control-flow structure here

class repeat (op: =>Unit) {
//
}

def until (cond: =>Boolean){
if (!cond) {
repeat
}
}


var i = 0
repeat {
if ( (i % 2) == 0 )
Expand Down
8 changes: 8 additions & 0 deletions src/main/scala/internal/WhileContinue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ object WhileContinue extends App {

// define the new control-flow structures here

def while_c (bool: =>Boolean) (body: =>Unit) {

}

def continue {

}

var i = -1

while_c (i < 9) {
Expand Down