Skip to content

Commit

Permalink
refactor(accumulate,list-ops,strain): revise to support test functions (
Browse files Browse the repository at this point in the history
  • Loading branch information
ajborla authored Jul 27, 2024
1 parent c8d5041 commit f5ce546
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 55 deletions.
7 changes: 0 additions & 7 deletions exercises/practice/accumulate/.meta/example.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,3 @@ Accumulate : procedure
output ||= retval ''
end
return STRIP(output, 'T')

/* Need to implement test helpers here, not in test runner file */
Dummy : ; return ''
Square : ; return ARG(1) * ARG(1)
ToUpperCase : ; return UPPER(ARG(1))
ReverseToken : ; return REVERSE(ARG(1))
GenSeq : if ARG(1) > 0 then ; return STRIP(GenSeq(ARG(1) - 1) ARG(1)) ; return ''
7 changes: 0 additions & 7 deletions exercises/practice/accumulate/accumulate.rexx
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
Accumulate : procedure
nop
return ''

/* Need to implement test helpers here, not in test runner file */
Dummy : ; return ''
Square : ; return ARG(1) * ARG(1)
ToUpperCase : ; return UPPER(ARG(1))
ReverseToken : ; return REVERSE(ARG(1))
GenSeq : if ARG(1) > 0 then ; return STRIP(GenSeq(ARG(1) - 1) ARG(1)) ; return ''
12 changes: 8 additions & 4 deletions exercises/practice/accumulate/testlib/accumulate-funcs.rexx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/* accumulate - Additional Test Functions */

/*
Include any test-callable, non-user-visible functions in this file.
These are meant to mimic lambda functions that are passed as arguments
to a higher order function. In the present case, the 'Accumulate' solution
procedure performs this role.
*/

Dummy : ; return ''
Square : ; return ARG(1) * ARG(1)
ToUpperCase : ; return UPPER(ARG(1))
ReverseToken : ; return REVERSE(ARG(1))
GenSeq : if ARG(1) > 0 then ; return STRIP(GenSeq(ARG(1) - 1) ARG(1)) ; return ''
9 changes: 0 additions & 9 deletions exercises/practice/list-ops/.meta/example.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,3 @@ ListReverse : procedure
output = elem output
end
return SPACE(output)

/* Need to implement test helpers here, not in test runner file */
IsEven : ; return ARG(1) // 2 == 0 /* Predicate (Filter) */
Add1 : ; return ARG(1) + 1 /* Transformer (Map) */

/* Reducers (FoldL and FoldR) */
Multiply : ; return ARG(1) * ARG(2) /* Direction independant */
IntegerDivide : ; return ARG(2) % ARG(1) /* Direction dependant */
Concatenate : ; return ARG(2) ARG(1) /* Ditto */
9 changes: 0 additions & 9 deletions exercises/practice/list-ops/list-ops.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,3 @@ return ''
ListReverse : procedure
nop
return ''

/* Need to implement test helpers here, not in test runner file */
IsEven : ; return ARG(1) // 2 == 0 /* Predicate (Filter) */
Add1 : ; return ARG(1) + 1 /* Transformer (Map) */

/* Reducers (FoldL and FoldR) */
Multiply : ; return ARG(1) * ARG(2) /* Direction independant */
IntegerDivide : ; return ARG(2) % ARG(1) /* Direction dependant */
Concatenate : ; return ARG(2) ARG(1) /* Ditto */
11 changes: 8 additions & 3 deletions exercises/practice/list-ops/testlib/list-ops-funcs.rexx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
/* list-ops - Additional Test Functions */

/*
Include any test-callable, non-user-visible functions in this file.
These are meant to mimic lambda functions that are passed as arguments
to a higher order function.
*/
IsEven : ; return ARG(1) // 2 == 0 /* Predicate (Filter) */
Add1 : ; return ARG(1) + 1 /* Transformer (Map) */

/* Reducers (FoldL and FoldR) */
Multiply : ; return ARG(1) * ARG(2) /* Direction independant */
IntegerDivide : ; return ARG(2) % ARG(1) /* Direction dependant */
Concatenate : ; return ARG(2) ARG(1) /* Ditto */
6 changes: 0 additions & 6 deletions exercises/practice/strain/.meta/example.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,3 @@ Discard : procedure
if \isTrue then ; output ||= token ''
end
return STRIP(output, 'T')

/* Need to implement test helpers here, not in test runner file */
LessThan10 : ; return ARG(1) < 10
IsOdd : ; return ARG(1) // 2 > 0
IsEven : ; return ARG(1) // 2 == 0
StartsWithZ : ; return SUBSTR(ARG(1), 1, 1) == 'z'
6 changes: 0 additions & 6 deletions exercises/practice/strain/strain.rexx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,3 @@ return ''
Discard : procedure
nop
return ''

/* Need to implement test helpers here, not in test runner file */
LessThan10 : ; return ARG(1) < 10
IsOdd : ; return ARG(1) // 2 > 0
IsEven : ; return ARG(1) // 2 == 0
StartsWithZ : ; return SUBSTR(ARG(1), 1, 1) == 'z'
11 changes: 7 additions & 4 deletions exercises/practice/strain/testlib/strain-funcs.rexx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/* strain - Additional Test Functions */

/*
Include any test-callable, non-user-visible functions in this file.
These are meant to mimic lambda functions that are passed as arguments
to a higher order function. In the present case, the 'Keep' and 'Discard'
solution procedures perform this role.
*/

LessThan10 : ; return ARG(1) < 10
IsOdd : ; return ARG(1) // 2 > 0
IsEven : ; return ARG(1) // 2 == 0
StartsWithZ : ; return SUBSTR(ARG(1), 1, 1) == 'z'

0 comments on commit f5ce546

Please sign in to comment.