| #------------------------------------------------------------- |
| # |
| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| # |
| #------------------------------------------------------------- |
| |
| rows = as.integer($1) |
| |
| # Original test sequences (positive increments) |
| A1 = rev(seq(0, rows-1, 1)) # Should become seq(rows-1, 0, -1) |
| A2 = rev(seq(0, rows, 2)) # Should become seq(rows, 0, -2) |
| A3 = rev(seq(2, rows, 2)) # Should become seq(lastVal, 2, -2) where lastVal is the last value in the sequence |
| A4 = rev(seq(0, 100, 5)) # Should become seq(100, 0, -5) |
| A5 = rev(seq(15, 5, -0.5)) # Should become seq(5, 15, 0.5) |
| |
| # Sum all sequences |
| R = sum(A1) + sum(A2) + sum(A3) + sum(A4) + sum(A5) |
| |
| # Output |
| write(R, $2) |