From 5d2937612a8c034cc2c94bdd69be65e5d87fa73c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 3 Aug 2015 10:09:59 -0700 Subject: 1926 http://250bpm.com/blog:57 Funnily, the new idea I finally came up with in 'read' was already mirrored above in recipe 'write'. --- 060string.mu | 2 +- 061channel.mu | 2 +- 071print.mu | 12 ++++-------- edit.mu | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/060string.mu b/060string.mu index a212b75b..e6cd72f5 100644 --- a/060string.mu +++ b/060string.mu @@ -621,7 +621,7 @@ recipe trim [ # result = new character[end+1 - start] new-len:number <- subtract end, start, -1 result:address:array:character <- new character:type, new-len - # i = start, j = 0 + # copy the untrimmed parts between start and end i:number <- copy start j:number <- copy 0 { diff --git a/061channel.mu b/061channel.mu index 3470cc14..9f4ea619 100644 --- a/061channel.mu +++ b/061channel.mu @@ -94,7 +94,7 @@ recipe read [ full:address:number <- get-address *chan, first-full:offset circular-buffer:address:array:location <- get *chan, data:offset result:location <- index *circular-buffer, *full - # increment full + # mark its slot as empty *full <- add *full, 1 { # wrap full around to 0 if necessary diff --git a/071print.mu b/071print.mu index 075318a9..82677f7e 100644 --- a/071print.mu +++ b/071print.mu @@ -434,13 +434,12 @@ recipe cursor-down [ { break-unless sc { - # if row < height-1 + # increment row unless it's already all the way down height:number <- get *sc, num-rows:offset row:address:number <- get-address *sc, cursor-row:offset max:number <- subtract height, 1 at-bottom?:boolean <- greater-or-equal *row, max break-if at-bottom? - # row = row+1 *row <- add *row, 1 } reply sc/same-as-ingredient:0 @@ -457,11 +456,10 @@ recipe cursor-up [ { break-unless sc { - # if row > 0 + # decrement row unless it's already all the way up row:address:number <- get-address *sc, cursor-row:offset at-top?:boolean <- lesser-or-equal *row, 0 break-if at-top? - # row = row-1 *row <- subtract *row, 1 } reply sc/same-as-ingredient:0 @@ -478,13 +476,12 @@ recipe cursor-right [ { break-unless sc { - # if column < width-1 + # increment column unless it's already all the way to the right width:number <- get *sc, num-columns:offset column:address:number <- get-address *sc, cursor-column:offset max:number <- subtract width, 1 at-bottom?:boolean <- greater-or-equal *column, max break-if at-bottom? - # column = column+1 *column <- add *column, 1 } reply sc/same-as-ingredient:0 @@ -501,11 +498,10 @@ recipe cursor-left [ { break-unless sc { - # if column > 0 + # decrement column unless it's already all the way to the left column:address:number <- get-address *sc, cursor-column:offset at-top?:boolean <- lesser-or-equal *column, 0 break-if at-top? - # column = column-1 *column <- subtract *column, 1 } reply sc/same-as-ingredient:0 diff --git a/edit.mu b/edit.mu index 40819a62..a3235e79 100644 --- a/edit.mu +++ b/edit.mu @@ -2994,7 +2994,7 @@ recipe restore-sandboxes [ expected-response:address:address:array:character <- get-address **curr, expected-response:offset *expected-response <- copy contents } - # increment loop variables + +continue idx <- add idx, 1 curr <- get-address **curr, next-sandbox:offset loop -- cgit 1.4.1-2-gfad0