Interactive programming (repl)

Revision as of 17:18, 21 February 2009 by rosettacode>Paddy3118 (New page: {{task}} Many languages come with a command line interpreter or shell. Show how to start the interpreter, then interactively create a function of two stri...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Many languages come with a command line interpreter or shell.

Task
Interactive programming (repl)
You are encouraged to solve this task according to the task description, using any language you may know.

Show how to start the interpreter, then interactively create a function of two strings and a separator that returns the strings separated by two concatenated instances of the separator.

For example, f('Rosetta', 'Code', ':') should return 'Rosetta::Code'

Note: this task is not about creating your own interpreter.

Python

Start the interpreter by typing python at the command line (or select it from a menu). You get a response showing the version of the interpreter being run before giving an inpt prompt of three greater-than characters and a space:

<lang python>python Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> def f(string1, string2, separator): return separator.join([string1, , string2])

>>> f('Rosetta', 'Code', ':') 'Rosetta::Code' >>>