Skip to content

Commit d231411

Browse files
committed
Updating Ch02 Factorial example to work with BSD. Closes Issue #87
1 parent 556106e commit d231411

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

book/02.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ Shell Function
225225
: A shell function is a function that is, in our case executed by Bash. They provide similar functionality to a Bash script, but they are usually (but not necessarily) smaller than scripts. They also tend to be more personal. The following command defines a function called `fac`, which, just like the interpreted Python script above, computes the factorial of the integer we pass as a parameter. It does by generating a list of numbers using `seq`, putting those numbers on one line with `*` as the delimiter using `paste` [@paste], and passing this equation into `bc` [@bc], which is evaluates it and outputs the result.
226226

227227
```{bash, eval=FALSE}
228-
$ fac() { (echo 1; seq $1) | paste -s -d\* | bc; }
228+
$ fac() { (echo 1; seq $1) | paste -s -d\* - | bc; }
229229
$ fac 5
230230
120
231231
```
@@ -264,7 +264,7 @@ fac is a function
264264
fac ()
265265
{
266266
( echo 1;
267-
seq $1 ) | paste -s -d\* | bc
267+
seq $1 ) | paste -s -d\* - | bc
268268
}
269269
$ type -a l
270270
l is aliased to `ls -1 --group-directories-first'

0 commit comments

Comments
 (0)