From: "Mauricio Fernández" Date: 2003-04-12T05:17:33+09:00 Subject: Re: splat question On Sat, Apr 12, 2003 at 02:41:14AM +0900, Chris Pine wrote: > (This question assumes that the unary `*' (used in arrays and such) is > called "splat". If not, please translate this into something which makes > sense.) > > I was wondering if there's a reason we couldn't splat an array into itself. > There's no way currently to do it (no syntax for it), but would it be > impossible to do? I was thinking something like this would produce an > infinite array of ones: > > a = [1, *a] # Doesn't work because `a' isn't defined. > > or this: > > a = [1] > a << *a # Parse error. > > or this: > > a = [1] > a[1] = *a > a # --> [1, 1] (Of course.) > > > Would this be impossible because when a splat is encountered, the objects > are injected into the other array at that moment? (It seems like Ruby could > just wait on that.) ========== > > It's just one of those things from functional programming that I don't see > how to do in Ruby. This sounds like lazy evaluation, the kind of stuff you can find around implemented with continuations. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com C:\> WIN Bad command or filename C:\> LOSE Loading Microsoft Windows ...