[swift-users] read data from the code

David Turnbull dturnbull at gmail.com
Sat Dec 12 02:37:47 CST 2015


I couldn't figure out a way to bring back line numbers but here's READ and
DATA...

// Define your data

let DATA = [5,7,1,6,7]

// Change the Int below to whatever type of DATA you have

let READ = {() -> () -> Int

    in var g=DATA.generate();return {()in return g.next()!}}()

// And now you read

print( READ() )

print( READ() + READ() )

print( READ() * READ() )


It's like magic and stuff.

-david



On Fri, Dec 11, 2015 at 10:46 PM, Bee via swift-users <swift-users at swift.org
> wrote:

> Hi all,
>
> Does anyone here remember gwbasic? There is one feature of gwbasic that I
> miss from modern programming language. It's the pair of READ function and
> DATA statement. An example here:
> http://www.antonis.de/qbebooks/gwbasman/data.html
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151212/0da9a157/attachment.html>


More information about the swift-users mailing list