Re: [R] strange output of cat function used in recursive function

2016-10-01 Thread David Winsemius
> On Oct 1, 2016, at 9:39 AM, David Winsemius wrote: > > >> On Oct 1, 2016, at 9:29 AM, Jan Kacaba wrote: >> >> 2016-10-01 18:02 GMT+02:00 David Winsemius : >>> On Oct 1, 2016, at 8:44 AM, Jan Kacaba

Re: [R] strange output of cat function used in recursive function

2016-10-01 Thread David Winsemius
> On Oct 1, 2016, at 9:29 AM, Jan Kacaba wrote: > > 2016-10-01 18:02 GMT+02:00 David Winsemius : >> >>> On Oct 1, 2016, at 8:44 AM, Jan Kacaba wrote: >>> >>> Hello Dear R-help >>> >>> I tried to understand how recursive

Re: [R] strange output of cat function used in recursive function

2016-10-01 Thread Jan Kacaba
2016-10-01 18:02 GMT+02:00 David Winsemius : > >> On Oct 1, 2016, at 8:44 AM, Jan Kacaba wrote: >> >> Hello Dear R-help >> >> I tried to understand how recursive programming works in R. Bellow is >> simple recursive function. >> >> binary1 <-

Re: [R] strange output of cat function used in recursive function

2016-10-01 Thread David Winsemius
> On Oct 1, 2016, at 8:44 AM, Jan Kacaba wrote: > > Hello Dear R-help > > I tried to understand how recursive programming works in R. Bellow is > simple recursive function. > > binary1 <- function(n) { > if(n > 1) { >binary(as.integer(n/2)) > } > cat(n %% 2) > }

[R] strange output of cat function used in recursive function

2016-10-01 Thread Jan Kacaba
Hello Dear R-help I tried to understand how recursive programming works in R. Bellow is simple recursive function. binary1 <- function(n) { if(n > 1) { binary(as.integer(n/2)) } cat(n %% 2) } When I call binary1(10) I get 1010. I believe that cat function stores value to a buffer