/* ARM assembly Raspberry PI  */
/*  program inputText.s   */

/* Constantes    */
.equ BUFFERSIZE,   100
.equ STDIN,  0     @ Linux input console
.equ STDOUT, 1     @ Linux output console
.equ EXIT,   1     @ Linux syscall
.equ READ,   3     @ Linux syscall
.equ WRITE,  4     @ Linux syscall
/* Initialized data */
.data
szMessDeb: .asciz "Enter text : \n"
szMessNum: .asciz "Enter number : \n"
szCarriageReturn:  .asciz "\n"

/* UnInitialized data */
.bss
sBuffer:    .skip    BUFFERSIZE

/*  code section */
.text
.global main
main:                /* entry of program  */
    push {fp,lr}    /* saves 2 registers */
    ldr r0,iAdrszMessDeb
    bl affichageMess
    mov r0,#STDIN         @ Linux input console
    ldr r1,iAdrsBuffer   @ buffer address
    mov r2,#BUFFERSIZE   @ buffer size
    mov r7, #READ         @ request to read datas
    swi 0                  @ call system
    ldr r1,iAdrsBuffer    @ buffer address
    mov r2,#0                @ end of string
    strb r2,[r1,r0]         @ store byte at the end of input string (r0 contains number of characters)

    ldr r0,iAdrsBuffer    @ buffer address
    bl affichageMess
    ldr r0,iAdrszCarriageReturn
    bl affichageMess

    ldr r0,iAdrszMessNum
    bl affichageMess
    mov r0,#STDIN         @ Linux input console
    ldr r1,iAdrsBuffer   @ buffer address
    mov r2,#BUFFERSIZE   @ buffer size
    mov r7, #READ         @ request to read datas
    swi 0                  @ call system
    ldr r1,iAdrsBuffer    @ buffer address
    mov r2,#0                @ end of string
    strb r2,[r1,r0]         @ store byte at the end of input string (r0
    @
    ldr r0,iAdrsBuffer    @ buffer address
    bl conversionAtoD    @ conversion string in number in r0

100:   /* standard end of the program */
    mov r0, #0                  @ return code
    pop {fp,lr}                 @restaur 2 registers
    mov r7, #EXIT              @ request to exit program
    swi 0                       @ perform the system call

iAdrszMessDeb:  .int szMessDeb
iAdrszMessNum: .int  szMessNum
iAdrsBuffer:   .int  sBuffer
iAdrszCarriageReturn:  .int  szCarriageReturn
/******************************************************************/
/*     display text with size calculation                         */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
    push {fp,lr}    			/* save  registres */
    push {r0,r1,r2,r7}    		/* save others registers */
    mov r2,#0   				/* counter length */
1:      	/* loop length calculation */
    ldrb r1,[r0,r2]  			/* read octet start position + index */
    cmp r1,#0       			/* if 0 its over */
    addne r2,r2,#1   			/* else add 1 in the length */
    bne 1b          			/* and loop */
                                /* so here r2 contains the length of the message */
    mov r1,r0        			/* address message in r1 */
    mov r0,#STDOUT      		/* code to write to the standard output Linux */
    mov r7, #WRITE             /* code call system "write" */
    swi #0                      /* call systeme */
    pop {r0,r1,r2,r7}     		/* restaur others registers */
    pop {fp,lr}    				/* restaur des  2 registres */
    bx lr	        			/* return  */

/******************************************************************/
/*     Convert a string to a number stored in a registry          */
/******************************************************************/
/* r0 contains the address of the area terminated by 0 or 0A */
/* r0 returns a number                           */
conversionAtoD:
    push {fp,lr}         @ save 2 registers
    push {r1-r7}         @ save others registers
    mov r1,#0
    mov r2,#10           @ factor
    mov r3,#0            @ counter
    mov r4,r0            @ save address string -> r4
    mov r6,#0            @ positive sign by default
    mov r0,#0            @ initialization to 0
1:     /* early space elimination loop */
    ldrb r5,[r4,r3]     @ loading in r5 of the byte located at the beginning + the position
    cmp r5,#0            @ end of string -> end routine
    beq 100f
    cmp r5,#0x0A        @ end of string -> end routine
    beq 100f
    cmp r5,#' '          @ space ?
    addeq r3,r3,#1      @ yes we loop by moving one byte
    beq 1b
    cmp r5,#'-'          @ first character is -
    moveq r6,#1         @  1 -> r6
    beq 3f              @ then move on to the next position
2:   /* beginning of digit processing loop */
    cmp r5,#'0'          @ character is not a number
    blt 3f
    cmp r5,#'9'          @ character is not a number
    bgt 3f
    /* character is a number */
    sub r5,#48
    ldr r1,iMaxi       @ check the overflow of the register
    cmp r0,r1
    bgt 99f            @ overflow error
    mul r0,r2,r0         @ multiply par factor 10
    add r0,r5            @ add to  r0
3:
    add r3,r3,#1         @ advance to the next position
    ldrb r5,[r4,r3]     @ load byte
    cmp r5,#0            @ end of string -> end routine
    beq 4f
    cmp r5,#0x0A            @ end of string -> end routine
    beq 4f
    b 2b                 @ loop
4:
    cmp r6,#1            @ test r6 for sign
    moveq r1,#-1
    muleq r0,r1,r0       @ if negatif, multiply par -1
    b 100f
99:  /* overflow error */
    ldr r0,=szMessErrDep
    bl   affichageMess
    mov r0,#0      @ return  zero  if error
100:
    pop {r1-r7}          @ restaur other registers
    pop {fp,lr}          @ restaur   2 registers
    bx lr                 @return procedure
/* constante program */
iMaxi: .int 1073741824
szMessErrDep:  .asciz  "Too large: overflow 32 bits.\n"


#include <stdio.h>

void vc(int n, int base, int *num, int *denom)
{
        int p = 0, q = 1;

        while (n) {
                p = p * base + (n % base);
                q *= base;
                n /= base;
        }

        *num = p;
        *denom = q;

        while (p) { n = p; p = q % p; q = n; }
        *num /= q;
        *denom /= q;
}

int main()
{
        int d, n, i, b;
        for (b = 2; b < 6; b++) {
                printf("base %d:", b);
                for (i = 0; i < 10; i++) {
                        vc(i, b, &n, &d);
                        if (n) printf("  %d/%d", n, d);
                        else   printf("  0");
                }
                printf("\n");
        }

        return 0;
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VanDerCorput
{
    /// <summary>
    /// Computes the Van der Corput sequence for any number base.
    /// The numbers in the sequence vary from zero to one, including zero but excluding one.
    /// The sequence possesses low discrepancy.
    /// Here are the first ten terms for bases 2 to 5:
    ///
    /// base 2:  0  1/2  1/4  3/4  1/8  5/8  3/8  7/8  1/16  9/16
    /// base 3:  0  1/3  2/3  1/9  4/9  7/9  2/9  5/9  8/9  1/27
    /// base 4:  0  1/4  1/2  3/4  1/16  5/16  9/16  13/16  1/8  3/8
    /// base 5:  0  1/5  2/5  3/5  4/5  1/25  6/25  11/25  16/25  21/25
    /// </summary>
    /// <see cref="http://rosettacode.org/wiki/Van_der_Corput_sequence"/>
    public class VanDerCorputSequence: IEnumerable<Tuple<long,long>>
    {
        /// <summary>
        /// Number base for the sequence, which must bwe two or more.
        /// </summary>
        public int Base { get; private set; }

        /// <summary>
        /// Maximum number of terms to be returned by iterator.
        /// </summary>
        public long Count { get; private set; }

        /// <summary>
        /// Construct a sequence for the given base.
        /// </summary>
        /// <param name="iBase">Number base for the sequence.</param>
        /// <param name="count">Maximum number of items to be returned by the iterator.</param>
        public VanDerCorputSequence(int iBase, long count = long.MaxValue) {
            if (iBase < 2)
                throw new ArgumentOutOfRangeException("iBase", "must be two or greater, not the given value of " + iBase);
            Base = iBase;
            Count = count;
        }

        /// <summary>
        /// Compute nth term in the Van der Corput sequence for the base specified in the constructor.
        /// </summary>
        /// <param name="n">The position in the sequence, which may be zero or any positive number.</param>
        /// This number is always an integral power of the base.</param>
        /// <returns>The Van der Corput sequence value expressed as a Tuple containing a numerator and a denominator.</returns>
        public Tuple<long,long> Compute(long n)
        {
            long p = 0, q = 1;
            long numerator, denominator;
            while (n != 0)
            {
                p = p * Base + (n % Base);
                q *= Base;
                n /= Base;
            }
            numerator = p;
            denominator = q;
            while (p != 0)
            {
                n = p;
                p = q % p;
                q = n;
            }
            numerator /= q;
            denominator /= q;
            return new Tuple<long,long>(numerator, denominator);
        }

        /// <summary>
        /// Compute nth term in the Van der Corput sequence for the given base.
        /// </summary>
        /// <param name="iBase">Base to use for the sequence.</param>
        /// <param name="n">The position in the sequence, which may be zero or any positive number.</param>
        /// <returns>The Van der Corput sequence value expressed as a Tuple containing a numerator and a denominator.</returns>
        public static Tuple<long, long> Compute(int iBase, long n)
        {
            var seq = new VanDerCorputSequence(iBase);
            return seq.Compute(n);
        }

        /// <summary>
        /// Iterate over the Van Der Corput sequence.
        /// The first value in the sequence is always zero, regardless of the base.
        /// </summary>
        /// <returns>A tuple whose items are the Van der Corput value given as a numerator and denominator.</returns>
        public IEnumerator<Tuple<long, long>> GetEnumerator()
        {
            long iSequenceIndex = 0L;
            while (iSequenceIndex < Count)
            {
                yield return Compute(iSequenceIndex);
                iSequenceIndex++;
            }
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            TestBasesTwoThroughFive();

            Console.WriteLine("Type return to continue...");
            Console.ReadLine();
        }

        static void TestBasesTwoThroughFive()
        {
            foreach (var seq in Enumerable.Range(2, 5).Select(x => new VanDerCorputSequence(x, 10))) // Just the first 10 elements of the each sequence
            {
                Console.Write("base " + seq.Base + ":");
                foreach(var vc in seq)
                    Console.Write(" " + vc.Item1 + "/" + vc.Item2);
                Console.WriteLine();
            }
        }
    }
}


fcn dotp(a,b){ a.zipWith('*,b).sum() } //1 slow but concise
fcn crossp([(a1,a2,a3)],[(b1,b2,b3)])  //2
   { return(a2*b3 - a3*b2, a3*b1 - a1*b3, a1*b2 - a2*b1) }


str: input "Enter a string: "
num: to :integer input "Enter an integer: "

print ["Got:" str "," num]


DllCall("AllocConsole")
FileAppend, please type something`n, CONOUT$
FileReadLine, line, CONIN$, 1
msgbox % line
FileAppend, please type '75000'`n, CONOUT$
FileReadLine, line, CONIN$, 1
msgbox % line


~/src/opt/run $ awk 'BEGIN{printf "enter a string: "}{s=$0;i=$0+0;print "ok,"s"/"i}'
enter a string: hello world
ok,hello world/0
75000
ok,75000/75000


#include <cmath>
#include <iostream>

double vdc(int n, double base = 2)
{
    double vdc = 0, denom = 1;
    while (n)
    {
        vdc += fmod(n, base) / (denom *= base);
        n /= base; // note: conversion from 'double' to 'int'
    }
    return vdc;
}

int main()
{
    for (double base = 2; base < 6; ++base)
    {
        std::cout << "Base " << base << "\n";
        for (int n = 0; n < 10; ++n)
        {
            std::cout << vdc(n, base) << " ";
        }
        std::cout << "\n\n";
    }
}


(defn van-der-corput
  "Get the nth element of the van der Corput sequence."
  ([n]
   ;; Default base = 2
   (van-der-corput n 2))
  ([n base]
   (let [s (/ 1 base)]  ;; A multiplicand to shift to the right of the decimal.
     ;; We essentially want to reverse the digits of n and put them after the
     ;; decimal point. So, we repeatedly pull off the lowest digit of n, scale
     ;; it to the right of the decimal point, and accumulate that.
     (loop [sum 0
            n n
            scale s]
       (if (zero? n)
         sum  ;; Base case: no digits left, so we're done.
         (recur (+ sum (* (rem n base) scale))  ;; Accumulate the least digit
                (quot n base)                   ;; Drop a digit of n
                (* scale s)))))))               ;; Move farther past the decimal

(clojure.pprint/print-table
  (cons :base (range 10))  ;; column headings
  (for [base (range 2 6)]  ;; rows
    (into {:base base}
          (for [n (range 10)]  ;; table entries
            [n (van-der-corput n base)]))))


Disp "String:"
input→A
length(A)→L

.Copy the string to a safe location
Copy(A,L₁,L)

.Display the string
Disp "You entered:",i
For(I,0,L-1)
 Disp {L₁+I}►Char
End
Disp i

Disp "Integer:",i
input→B
length(B)→L

.Parse the string and convert to an integer
0→C
For(I,0,L-1)
 {B+I}-'0'→N
 If N>10
  .Error checking
  Disp "Not a number",i
  Return
 End
 C*10+N→C
End

.Display and check the integer
Disp "You entered:",i,C►Dec,i
If C≠7500
Disp "That isn't 7500"
End


INPUT "Enter a string"; s$
INPUT "Enter a number: ", i%


      INPUT LINE "Enter a string: " string$
      INPUT "Enter a number: " number

      PRINT "String = """ string$ """"
      PRINT "Number = " ; number


<>:v:"Enter a string: "
 ^,_ >~:1+v
     ^    [email protected]


vc = proc (n, base: int) returns (int, int)
    p: int := 0
    q: int := 1
    while n ~= 0 do
        p := p * base + n // base
        q := q * base
        n := n / base
    end
    num: int := p
    denom: int := q
    while p ~= 0 do
        p, q := q // p, p
    end
    return(num/q, denom/q)
end vc

print_frac = proc (po: stream, num, denom: int)
    if num=0 then
        stream$puts(po, "   0")
    else
        stream$puts(po, " ")
        stream$putright(po, int$unparse(num), 2)
        stream$puts(po, "/")
        stream$putright(po, int$unparse(denom), 2)
    end
end print_frac

start_up = proc ()
    po: stream := stream$primary_output()
    for base: int in int$from_to(2,5) do
        stream$puts(po, "base " || int$unparse(base) || ":")
        for i: int in int$from_to(0, 9) do
            n, d: int := vc(i, base)
            print_frac(po, n, d)
        end
        stream$putl(po, "")
    end
end start_up


(defun van-der-Corput (n base)
  (loop for d = 1 then (* d base) while (<= d n)
	finally
	(return (/ (parse-integer
		     (reverse (write-to-string n :base base))
		     :radix base)
		   d))))

(loop for base from 2 to 5 do
      (format t "Base ~a: ~{~6a~^~}~%" base
	      (loop for i to 10 collect (van-der-Corput i base))))


include "cowgol.coh";

sub vc(n: uint16, base: uint16): (num: uint16, denom: uint16) is
    var p: uint16 := 0;
    var q: uint16 := 1;

    while n != 0 loop
        p := p * base + n % base;
        q := q * base;
        n := n / base;
    end loop;

    num := p;
    denom := q;

    while p != 0 loop
        n := p;
        p := q % p;
        q := n;
    end loop;

    num := num / q;
    denom := denom / q;
end sub;

sub printfrac(num: uint16, denom: uint16) is
    if num == 0 then
        print("  0");
    else
        print("  ");
        print_i16(num);
        print("/");
        print_i16(denom);
    end if;
end sub;

var i: uint16;
var base: uint16;
var num: uint16;
var denom: uint16;

base := 2;
while base < 6 loop
    print("base ");
    print_i16(base);
    print(":");
    i := 0;
    while i < 10 loop
        (num, denom) := vc(i, base);
        printfrac(num, denom);
        i := i + 1;
    end loop;
    print_nl();
    base := base + 1;
end loop;


( doit
=   out'"Enter a string"
  & get':?mystring
  &   whl
    ' ( out'"Enter a number"
      & get':?mynumber
      & !mynumber:~#
      & out'"I said:\"a number\"!"
      )
  & out$(mystring is !mystring \nmynumber is !mynumber \n)
);


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    // Get a string from stdin
    char str[BUFSIZ];
    puts("Enter a string: ");
    fgets(str, sizeof(str), stdin);

    // Get 75000 from stdin
    long num;
    char buf[BUFSIZ];
    do
    {
        puts("Enter 75000: ");
        fgets(buf, sizeof(buf), stdin);
        num = strtol(buf, NULL, 10);
    } while (num != 75000);

    return EXIT_SUCCESS;
}


using System;

namespace C_Sharp_Console {

    class example {

        static void Main() {
            string word;
            int num;

            Console.Write("Enter an integer: ");
            num = Console.Read();
            Console.Write("Enter a String: ");
            word = Console.ReadLine();
        }
    }
}


double vdc(int n, in double base=2.0) pure nothrow @safe @nogc {
    double vdc = 0.0, denom = 1.0;
    while (n) {
        denom *= base;
        vdc += (n % base) / denom;
        n /= base;
    }
    return vdc;
}

void main() {
    import std.stdio, std.algorithm, std.range;

    foreach (immutable b; 2 .. 6)
        writeln("\nBase ", b, ": ", 10.iota.map!(n => vdc(n, b)));
}


func vdc b n . v .
  s = 1
  v = 0
  while n > 0
    s *= b
    m = n mod b
    v += m / s
    n = n div b
  .
.
for b = 2 to 5
  write "base " & b & ":"
  for n range 10
    call vdc b n v
    write " " & v
  .
  print ""
.


[Van der Corput sequence for Rosetta Code.
 EDSAC solution, Initial Orders 2.]

[Library subroutine M3 - prints header at load time and is then overwritten.
 Here, the last character sets the teleprinter to figures.]
            [email protected]@E8FEZPF
            *[email protected]&#17A*BIT!!!#35A*[email protected]&#
            ..PZ [blank tape then re-sync]

[Define load addresses]
            T55K P100F  [V parameter: van der Corput subroutines]
            T51K P64F   [G parameter: print subroutine]
            T47K P400F  [M parameter: main routine]

[Subroutines to return n'th element of van der Corput sequence.
 17-bit version: Call by GV, pass n in 0F (not preserved), result in 4F.
 35-bit version: Call by G1V, pass n in 0D (not preserved), result in 4D.]
            E25K TV GK
            [email protected]  [jump to 17-bit version]
            [email protected] [jump to 35-bit version]
[17-bit version.
 On EDSAC, it's a matter of reversing the bits after the binary point
 To save time, we use a table to reverse the 16 bits in groups of 4.]
      [2]   A3F [email protected]    [plant return link as usual]
            H5 [email protected]       [set mult reg to 0...01111 binary]
            [email protected] T4F    [set marker bit 0...01 in result]
      [7]   A4F L4F T4F [shift result 4 left]
            CF          [acc := next 4 bits of n]
            LD          [shift into address field]
            [email protected] [email protected]   [plant A order to load from table]
     [14]   AF          [{planted) load bits from table]
            A4F         [add to result]
            [email protected]        [jump out if marker bit has reached sign bit]
            T4F         [update result]
            AF R4F TF   [shift n 4 right]
            [email protected]         [always loop back]
     [22]   [email protected]        [done, remove marker bit]
            T4F         [store final result]
     [24]   ZF          [(planted) jump to return to caller]

[35-bit version. Very similar to the 17-bit version, except that
 after reversing 8 groups of 4, there are 2 bits left over,
 which require separate treatment.]
     [25]   A3F [email protected]    [plant return link as usual]
            [email protected]        [set mult reg to 0...01111 binary]
            YF L2F      [set marker bit 0...0100 in result]
     [30]   L4F T4D     [shift result 4 left]
            CF LD [email protected] [email protected] AF A4F T4F [update from table as in 17-bit version]
            ADR4FTD     [shift n 4 right]
            A4D         [load result]
            [email protected]        [if marker bit hasn't reached sign bit, loop back]
[Last 2 bits]
     [44]   L1FT4D      [shift result 2 right]
            CF LD [email protected] [email protected] [plant A order as in 17-bit version]
     [50]   AF          [Planted) load bits from table]
            R1F A4F T4F [shift table entry 2 right and add to result]
     [54]   ZF          [(planted) jump to return to caller]
[Constants]
     [55]   PD          [17-bit 1]
     [56]   P7D         [17-bit 15]
     [57]   K4096F      [17-bit 10...0 binary]
     [58]   [email protected]        [order to load from table{0}]
[Table to reverse group of 4 bits, e.g. table{0010b} = 0100b]
     [59]   PFP4FP2FP6FP1FP5FP3FP7FPDP4DP2DP6DP1DP5DP3DP7D

[Library subroutine P1 to print number in range 0 <= x < 1.
 Caller must print leading '0.' if required. 21 storage locations.]
            E25K TG
            [email protected]@[email protected]@[email protected]@[email protected]@EFU3FJFM1F

[Main routine]
            E25K TM GK
      [0]   PF PF       [n, 35 bits, must be at even address]
      [2]   PF          [negative count of terms]
      [3]   P10F        [<=== EDIT number of terms, in address field]
      [4]   PD          [17-bit integer 1]
      [5]   MF          [dot (in figures mode)]
      [6]   @F          [carriage return]
      [7]   &F          [line feed]
      [8]   !F          [space character]
      [9]   K4096F      [null character]

[Enter with acc = 0]
     [10]   T#@         [n := 0]
            [email protected] [email protected]     [initialize negative count]
     [13]   [email protected] TF       [pass 17-bit n in 0F]
     [15]   [email protected] GV     [call 17-bit van der Corput routine]
            TD          [clear 0D, including sandwich bit]
            A4F T1F     [extend 17-bit result to 35 bits in 0D]
            [email protected] [email protected]     [print '0.']
     [22]   [email protected] GG P5F [print result to 5 decimals]
            [email protected] [email protected]     [print 2 spaces]
            A#@ TD      [pass 35-bit n in 0D]
     [29]   [email protected] G1V    [call 35-bit van der Corput routine]
            A4D TD      [pass result in 0D]
            [email protected] [email protected]     [print '0.']
     [35]   [email protected] GG P10F [print result to 10 decimals]
            [email protected] [email protected]     [print CR LF]
            [email protected] A2F     [inc negative count]
            [email protected]        [jump out if count = 0]
            [email protected]         [update count]
            [email protected] [email protected] [email protected]   [inc n]
            [email protected]        [loop back]
     [48]   [email protected]         [print null to flush teleprinter buffer]
            ZF          [stop]

            E10Z        [define entry point]
            PF          [acc = 0 on entry]
[end]


#include <iostream>
#include <string>
using namespace std;

int main()
{
     // while probably all current implementations have int wide enough for 75000, the C++ standard
     // only guarantees this for long int.
     long int integer_input;
     string string_input;
     cout << "Enter an integer:  ";
     cin >> integer_input;
     cout << "Enter a string:  ";
     cin >> string_input;
     return 0;
}


shared void run() {
	print("enter any text here");
	value text = process.readLine();
	print(text);
	print("enter the number 75000 here");
	if (is Integer number = Integer.parse(process.readLine() else "")) {
		print("``number == 75k then number else "close enough"``");
	}
	else {
		print("That was not a number per se.");
	}
}


(import '(java.util Scanner))
(def scan (Scanner. *in*))
(def s (.nextLine scan))
(def n (.nextInt scan))


       IDENTIFICATION DIVISION.
       PROGRAM-ID. Get-Input.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Input-String PIC X(30).
       01  Input-Int    PIC 9(5).

       PROCEDURE DIVISION.
       DISPLAY "Enter a string:"
       ACCEPT Input-String

       DISPLAY "Enter a number:"
       ACCEPT Input-Int

       GOBACK
       .


open random number list

vdc bs n = vdc' 0.0 1.0 n
  where vdc' v d n
          | n > 0 = vdc' v' d' n'
          | else  = v
          where
            d' = d * bs
            rem = n % bs
            n' = truncate (n / bs)
            v' = v + rem / d'


defmodule Van_der_corput do
  def sequence( n, base \\ 2 ) do
    "0." <> (Integer.to_string(n, base) |> String.reverse )
  end

  def float( n, base \\ 2 ) do
    Integer.digits(n, base) |> Enum.reduce(0, fn i,acc -> (i + acc) / base end)
  end

  def fraction( n, base \\ 2 ) do
    str = Integer.to_string(n, base) |> String.reverse
    denominator = Enum.reduce(1..String.length(str), 1, fn _,acc -> acc*base end)
    reduction( String.to_integer(str, base), denominator )
  end

  defp reduction( 0, _ ), do: "0"
  defp reduction( numerator, denominator ) do
    gcd = gcd( numerator, denominator )
    "#{ div(numerator, gcd) }/#{ div(denominator, gcd) }"
  end

  defp gcd( a, 0 ), do: a
  defp gcd( a, b ), do: gcd( b, rem(a, b) )
end

funs = [ {"Float(Base):",     &Van_der_corput.sequence/2},
         {"Float(Decimal):",  &Van_der_corput.float/2   },
         {"Fraction:",        &Van_der_corput.fraction/2} ]
Enum.each(funs, fn {title, fun} ->
  IO.puts title
  Enum.each(2..5, fn base ->
    IO.puts "  Base #{ base }: #{ Enum.map_join(0..9, ", ", &fun.(&1, base)) }"
  end)
end)


-module( van_der_corput ).

-export( [sequence/1, sequence/2, task/0] ).

sequence( N ) -> sequence( N, 2 ).

sequence( 0, _Base ) -> 0.0;
sequence( N, Base ) -> erlang:list_to_float( "0." ++ lists:flatten([erlang:integer_to_list(X) || X <- sequence_loop(N, Base)]) ).

task() -> [task(X) || X <- lists:seq(2, 5)].

sequence_loop( 0, _Base ) -> [];
sequence_loop( N, Base ) ->
	New_n = N div Base,
	Digit = N rem Base,
	[Digit | sequence_loop( New_n, Base )].

task( Base ) ->
	io:fwrite( "Base ~p:", [Base] ),
	[io:fwrite( " ~p", [sequence(X, Base)] ) || X <- lists:seq(0, 9)],
	io:fwrite( "~n" ).


(format t "Enter some text: ")
(let ((s (read-line)))
    (format t "You entered ~s~%" s))

(format t "Enter a number: ")
(let ((n (read)))
    (if (numberp n)
        (format t "You entered ~d.~%" n)
      (format t "That was not a number.")))


puts "You entered: #{gets}"

begin
  puts "You entered: #{gets.not_nil!.chomp.to_i}"
rescue ex
  puts ex
end


import std.stdio;

void main() {
    long number;
    write("Enter an integer: ");
    readf("%d", &number);

    char[] str;
    write("Enter a string: ");
    readf(" %s\n", &str);

    writeln("Read in '", number, "' and '", str, "'");
}


import 'dart:io' show stdout, stdin;

main() {
	stdout.write('Enter a string: ');
	final string_input = stdin.readLineSync();

	int number_input;

	do {
		stdout.write('Enter the number 75000: ');
		var number_input_string = stdin.readLineSync();

		try {
			number_input = int.parse(number_input_string);
			if (number_input != 75000)
				stdout.writeln('$number_input is not 75000!');
		} on FormatException {
			stdout.writeln('$number_input_string is not a valid number!');
		} catch ( e ) {
			stdout.writeln(e);
		}

	} while ( number_input != 75000 );

	stdout.writeln('input: $string_input\nnumber: $number_input');
}


PROGRAM VAN_DER_CORPUT

!
! for rosettacode.org
!

PROCEDURE VDC(N%,B%->RES)
      LOCAL V,S%
      S%=1
      WHILE N%>0 DO
        S%*=B%
        V+=(N% MOD B%)/S%
        N%=N% DIV B%
      END WHILE
      RES=V
END PROCEDURE

BEGIN
      FOR BASE%=2 TO 5 DO
        PRINT("Base";STR$(BASE%);":")
        FOR NUMBER%=0 TO 9 DO
          VDC(NUMBER%,BASE%->RES)
          WRITE("#.##### ";RES;)
        END FOR
        PRINT
      END FOR
END PROGRAM


function vdc(integer n, atom base)
    atom vdc, denom, rem
    vdc = 0
    denom = 1
    while n do
        denom *= base
        rem = remainder(n,base)
        n = floor(n/base)
        vdc += rem / denom
    end while
    return vdc
end function

for i = 2 to 5 do
    printf(1,"Base %d\n",i)
    for j = 0 to 9 do
        printf(1,"%g ",vdc(j,i))
    end for
    puts(1,"\n\n")
end for


open System

let vdc n b =
    let rec loop n denom acc =
        if n > 0l then
            let m, remainder = Math.DivRem(n, b)
            loop m (denom * b) (acc + (float remainder) / (float (denom * b)))
        else acc
    loop n 1 0.0

[<EntryPoint>]
let main argv =
    printfn "%A" [ for n in 0 .. 9 -> (vdc n 2) ]
    printfn "%A" [ for n in 0 .. 9 -> (vdc n 5) ]
    0


program UserInputText;

{$APPTYPE CONSOLE}

uses SysUtils;

var
  s: string;
  lStringValue: string;
  lIntegerValue: Integer;
begin
  WriteLn('Enter a string:');
  Readln(lStringValue);

  repeat
    WriteLn('Enter the number 75000');
    Readln(s);
    lIntegerValue := StrToIntDef(s, 0);
    if lIntegerValue <> 75000 then
      Writeln('Invalid entry: ' + s);
  until lIntegerValue = 75000;
end.


input s:
    !print\ s
    !decode!utf-8 !read-line!stdin
local :astring input "Enter a string: "
true
while:
    try:
        to-num input "Enter the number 75000: "
        /= 75000
    catch value-error:
        true


write "Enter a string: "
a$ = input
print ""
repeat
  write "Enter the number 75000: "
  h = number input
  print ""
  until h = 75000
.
print a$ & " " & h


import extensions;

public program()
{
    var num := new Integer();
    console.write:"Enter an integer: ".loadLineTo:num;

    var word := console.write:"Enter a String: ".readLine()
}


USING: formatting fry io kernel math math.functions math.parser
math.ranges sequences ;
IN: rosetta-code.van-der-corput

: vdc ( n base -- x )
    [ >base string>digits <reversed> ]
    [ nip '[ 1 + neg _ swap ^ * ] ] 2bi map-index sum ;

: vdc-demo ( -- )
    2 5 [a,b] [
        dup "Base %d: " printf 10 <iota>
        [ swap vdc "%-5u " printf ] with each nl
    ] each ;

MAIN: vdc-demo


: fvdc ( base n -- f )
  0e 1e ( F: vdc denominator )
  begin dup while
    over s>d d>f f*
    over /mod  ( base rem n )
    swap s>d d>f fover f/
    frot f+ fswap
  repeat 2drop fdrop ;

: test  10 0 do 2 i fvdc cr f. loop ;


      FUNCTION VDC(N,BASE)	!Calculates a Van der Corput number...
Converts 1234 in decimal to 4321 in V, and P = 10000.
       INTEGER N	!For this integer,
       INTEGER BASE	!In this base.
       INTEGER I	!A copy of N that can be damaged.
       INTEGER P	!Successive powers of BASE.
       INTEGER V	!Accumulates digits.
        P = 1		! = BASE**0
        V = 0		!Start with no digits, as if N = 0.
        I = N		!Here we go.
        DO WHILE (I .NE. 0)	!While something remains,
          V = V*BASE + MOD(I,BASE)	!Extract its low-order digit.
          I = I/BASE			!Reduce it by a power.
          P = P*BASE			!And track the power.
        END DO			!Thus extract the digits in reverse order: right-to-left.
        VDC = V/FLOAT(P)	!The power is one above the highest digit.
      END FUNCTION VDC	!Numerology is weird.

      PROGRAM POKE
      INTEGER FIRST,LAST	!Might as well document some constants.
      PARAMETER (FIRST = 0,LAST = 9)	!Thus, the first ten values.
      INTEGER I,BASE		!Steppers.
      REAL VDC			!Stop the compiler moaning about undeclared items.

      WRITE (6,1) FIRST,LAST,(I, I = FIRST,LAST)	!Announce.
    1 FORMAT ("Calculates values ",I0," to ",I0," of the ",
     1 "Van der Corput sequence, in various bases."/
     2 "Base",666I9)

      DO BASE = 2,13	!A selection of bases.
        WRITE (6,2) BASE,(VDC(I,BASE), I = FIRST,LAST)	!Show the specified span.
    2   FORMAT (I4,666F9.6)	!Aligns with FORMAT 1.
      END DO		!On to the next base.

      END


a = IO.gets("Enter a string: ")      |> String.strip
b = IO.gets("Enter an integer: ")    |> String.strip |> String.to_integer
f = IO.gets("Enter a real number: ") |> String.strip |> String.to_float
IO.puts "String  = #{a}"
IO.puts "Integer = #{b}"
IO.puts "Float   = #{f}"


{ok, [String]} = io:fread("Enter a string: ","~s").
{ok, [Number]} = io:fread("Enter a number: ","~d").


include get.e

sequence s
atom n

s = prompt_string("Enter a string:")
puts(1, s & '\n')
n = prompt_number("Enter a number:",{})
printf(1, "%d", n)


open System

let ask_for_input s =
    printf "%s (End with Return): " s
    Console.ReadLine()

[<EntryPoint>]
let main argv =
    ask_for_input "Input a string" |> ignore
    ask_for_input "Enter the number 75000" |> ignore
    0


' version 03-12-2016
' compile with: fbc -s console

Function num_base(number As ULongInt, _base_ As UInteger) As String

    If _base_ > 9 Then
        Print "base not handled by function"
        Sleep 5000
        Return ""
    End If

    Dim As ULongInt n
    Dim As String ans

    While number <> 0
        n = number Mod _base_
        ans = Str(n) + ans
        number = number \ _base_
    Wend

    If ans = "" Then ans = "0"

    Return "." + ans

End Function

' ------=< MAIN >=------

Dim As ULong k, l
For k = 2 To 5
    Print "Base = "; k
    For l = 0 To 12
        Print left(num_base(l, k) + "      ",6);
    Next
    Print : print
Next

' empty keyboard buffer
While Inkey <> "" : Wend
Print : Print "hit any key to end program"
Sleep
End


package main

import "fmt"

func v2(n uint) (r float64) {
    p := .5
    for n > 0 {
        if n&1 == 1 {
            r += p
        }
        p *= .5
        n >>= 1
    }
    return
}

func newV(base uint) func(uint) float64 {
    invb := 1 / float64(base)
    return func(n uint) (r float64) {
        p := invb
        for n > 0 {
            r += p * float64(n%base)
            p *= invb
            n /= base
        }
        return
    }
}

func main() {
    fmt.Println("Base 2:")
    for i := uint(0); i < 10; i++ {
        fmt.Println(i, v2(i))
    }
    fmt.Println("Base 3:")
    v3 := newV(3)
    for i := uint(0); i < 10; i++ {
        fmt.Println(i, v3(i))
    }
}


"Enter a string: " write
readln
"Enter a number: " write
readln string>number


printl("Enter a string:")
str = input()
printl("Enter a number:")
n = int(input())


class Main
{
  public static Void main ()
  {
    Env.cur.out.print ("Enter a string: ").flush
    str := Env.cur.in.readLine
    echo ("Entered :$str:")
    Env.cur.out.print ("Enter 75000: ").flush
    Int n
    try n = Env.cur.in.readLine.toInt
    catch (Err e)
    {
      echo ("You had to enter a number")
      return
    }
    echo ("Entered :$n: which is " + ((n == 75000) ? "correct" : "wrong"))
  }
}


: INPUT$ ( n -- addr n )
   PAD SWAP ACCEPT
   PAD SWAP ;


import Data.Ratio (Rational(..), (%), numerator, denominator)
import Data.List (unfoldr)
import Text.Printf (printf)

-- A wrapper type for Rationals to make them look nicer when we print them.
newtype Rat =
  Rat Rational

instance Show Rat where
  show (Rat n) = show (numerator n) <> ('/' : show (denominator n))

-- Convert a list of base b digits to its corresponding number.
-- We assume the digits are valid base b numbers and that
-- their order is from least to most significant.
digitsToNum :: Integer -> [Integer] -> Integer
digitsToNum b = foldr1 (\d acc -> b * acc + d)

-- Convert a number to the list of its base b digits.
-- The order will be from least to most significant.
numToDigits :: Integer -> Integer -> [Integer]
numToDigits _ 0 = [0]
numToDigits b n = unfoldr step n
  where
    step 0 = Nothing
    step m =
      let (q, r) = m `quotRem` b
      in Just (r, q)

-- Return the n'th element in the base b van der Corput sequence.
-- The base must be ≥ 2.
vdc :: Integer -> Integer -> Rat
vdc b n
  | b < 2 = error "vdc: base must be ≥ 2"
  | otherwise =
    let ds = reverse $ numToDigits b n
    in Rat (digitsToNum b ds % b ^ length ds)

-- Each base followed by a specified range of van der Corput numbers.
printVdcRanges :: ([Integer], [Integer]) -> IO ()
printVdcRanges (bases, nums) =
  mapM_
    putStrLn
    [ printf "Base %d:" b <> concatMap (printf " %5s" . show) rs
    | b <- bases
    , let rs = map (vdc b) nums ]

main :: IO ()
main = do
  -- Small bases:
  printVdcRanges ([2, 3, 4, 5], [0 .. 9])
  putStrLn []

  -- Base 123:
  printVdcRanges ([123], [50,100 .. 300])


character(20) :: s
integer :: i

print*, "Enter a string (max 20 characters)"
read*, s
print*, "Enter the integer 75000"
read*, i


' FB 1.05.0 Win64

Dim s As String
Dim i AS Integer
Input "Please enter a string : "; s
Do
  Input "Please enter 75000    : "; i
Loop Until i = 75000
Print
Print s, i
Sleep


s = input["Enter a string: "]
i = parseInt[input["Enter an integer: "]]


package main

import "fmt"

func main() {
    var s string
    var i int
    if _, err := fmt.Scan(&s, &i); err == nil && i == 75000 {
        fmt.Println("good")
    } else {
        fmt.Println("wrong")
    }
}


procedure main(A)
    base := integer(get(A)) | 2
    every writes(round(vdc(0 to 9,base),10)," ")
    write()
end

procedure vdc(n, base)
    e := 1.0
    x := 0.0
    while x +:= 1(((0 < n) % base) / (e *:= base), n /:= base)
    return x
end

procedure round(n,d)
    places := 10 ^ d
    return real(integer(n*places + 0.5)) / places
end


public class VanDerCorput{
	public static double vdc(int n){
		double vdc = 0;
		int denom = 1;
		while(n != 0){
			vdc += n % 2.0 / (denom *= 2);
			n /= 2;
		}
		return vdc;
	}

	public static void main(String[] args){
		for(int i = 0; i <= 10; i++){
			System.out.println(vdc(i));
		}
	}
}


word = System.in.readLine()
num = System.in.readLine().toInteger()


import System.IO (hFlush, stdout)
main = do
    putStr "Enter a string: "
    hFlush stdout
    str <- getLine
    putStr "Enter an integer: "
    hFlush stdout
    num <- readLn :: IO Int
    putStrLn $ str ++ (show num)


print "Enter a string: "
let s scan str
print "Enter a number: "
let n scan int


U8 *s;
s = GetStr("Enter a string: ");

U32 *n;
do {
  n = GetStr("Enter 75000: ");
} while(Str2I64(n) != 75000);

Print("Your string: %s\n", s);
Print("75000: %d\n", Str2I64(n));


# vdc(base) converts an input decimal integer to a decimal number based on the van der
# Corput sequence using base 'base', e.g. (4 | vdc(2)) is 0.125.
#
def vdc(base):

  # The helper function converts a stream of residuals to a decimal,
  # e.g. if base is 2, then decimalize( (0,0,1) ) yields 0.125
  def decimalize(stream):
    reduce stream as $d   # state: [accumulator, power]
      ( [0, 1/base];
       .[1] as $power | [ .[0] + ($d * $power), $power / base] )
    | .[0];

  if . == 0 then 0
  else decimalize(recurse( if . == 0 then empty else ./base | floor end ) % base)
  end ;


using Printf

vandercorput(num::Integer, base::Integer) = sum(d * Float64(base) ^ -ex for (ex, d) in enumerate(digits(num, base = base)))

for base in 2:9
    @printf("%10s %i:", "Base", base)
    for num in 0:9 @printf("%7.3f", vandercorput(num, base)) end
    println(" [...]")
end


// version 1.1.2

data class Rational(val num: Int, val denom: Int)

fun vdc(n: Int, base: Int): Rational {
    var p = 0
    var q = 1
    var nn = n
    while (nn != 0) {
        p = p * base + nn % base
        q *= base
        nn /= base
    }
    val num = p
    val denom = q
    while (p != 0) {
        nn = p
        p = q % p
        q = nn
    }
    return Rational(num / q, denom / q)
}

fun main(args: Array<String>) {
    for (b in 2..5) {
        print("base $b:")
        for (i in 0..9) {
            val(num, denom) = vdc(i, b)
            if (num != 0) print("  $num/$denom")
            else print("  0")
        }
        println()
    }
}


procedure main ()
  writes ("Enter something: ")
  s := read ()
  write ("You entered: " || s)

  writes ("Enter 75000: ")
  if (i := integer (read ())) then
    write (if (i = 75000) then "correct" else "incorrect")
  else write ("you must enter a number")
end


string := File clone standardInput readLine("Enter a string: ")
integer := File clone standardInput readLine("Enter 75000: ") asNumber


   require 'misc'            NB. load system script
   prompt 'Enter string: '
   0".prompt 'Enter an integer: '


import java.util.Scanner;

public class GetInput {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        System.out.print("Enter a string: ");
        String str = s.nextLine();
        System.out.print("Enter an integer: ");
        int i = Integer.parseInt(s.next());
    }
}


function vdc(n, base)
    local digits = {}
    while n ~= 0 do
        local m = math.floor(n / base)
        table.insert(digits, n - m * base)
        n = m
    end
    m = 0
    for p, d in pairs(digits) do
        m = m + math.pow(base, -p) * d
    end
    return m
end


VanDerCorput[n_,base_:2]:=Table[
  FromDigits[{Reverse[IntegerDigits[k,base]],0},base],
{k,n}]
VanDerCorput[10,2]
VanDerCorput[10,3]
VanDerCorput[10,4]
VanDerCorput[10,5]


    function x = corput (n)
    b = dec2bin(1:n)-'0';   % generate sequence of binary numbers from 1 to n
    l = size(b,2);          % get number of binary digits
    w = (1:l)-l-1;          % 2.^w are the weights
    x = b * ( 2.^w');       % matrix times vector multiplication for
    end;


WScript.Echo("Enter a string");
var str = WScript.StdIn.ReadLine();

var val = 0;
while (val != 75000) {
    WScript.Echo("Enter the integer 75000");
    val = parseInt( WScript.StdIn.ReadLine() );
}


"Enter a string: " putchars
stdin fgets
"Enter a number: " putchars
stdin fgets 10 strtol.


def read(int):
  null | until( . == int;  "Expecting \(int)" | stderr | input);

def read_string:
  null | until( type == "string";  "Please enter a string" | stderr | input);

(read_string | "I see the string: \(.)"),
(read(75000) | "I see the expected integer: \(.)")


print("String? ")
y = readline()
println("Your input was \"", y, "\".\n")
print("Integer? ")
y = readline()
try
    y = parse(Int, y)
    println("Your input was \"", y, "\".\n")
catch
    println("Sorry, but \"", y, "\" does not compute as an integer.")
end


/* convert a decimal integer to a list of digits in base `base' */
dec2digits(d, base):= block([digits: []],
  while (d>0) do block([newdi: mod(d, base)],
    digits: cons(newdi, digits),
    d: round( (d - newdi) / base)),
  digits)$

dec2digits(123, 10);
/* [1, 2, 3] */
dec2digits(  8,  2);
/* [1, 0, 0, 0] */


MODULE Sequence;
FROM FormatString IMPORT FormatString;
FROM Terminal IMPORT WriteString,WriteLn,ReadChar;

PROCEDURE vc(n,base : INTEGER; VAR num,denom : INTEGER);
VAR p,q : INTEGER;
BEGIN
    p := 0;
    q := 1;

    WHILE n#0 DO
        p := p * base + (n MOD base);
        q := q * base;
        n := n DIV base
    END;

    num := p;
    denom := q;

    WHILE p#0 DO
        n := p;
        p := q MOD p;
        q := n
    END;

    num := num DIV q;
    denom := denom DIV q
END vc;

VAR
    buf : ARRAY[0..31] OF CHAR;
    d,n,i,b : INTEGER;
BEGIN
    FOR b:=2 TO 5 DO
        FormatString("base %i:", buf, b);
        WriteString(buf);
        FOR i:=0 TO 9 DO
            vc(i,b,n,d);
            IF n#0 THEN
                FormatString("  %i/%i", buf, n, d);
                WriteString(buf)
            ELSE
                WriteString("  0")
            END
        END;
        WriteLn
    END;

    ReadChar
END Sequence.


import rationals, strutils, sugar

type Fract = Rational[int]

proc corput(n: int; base: Positive): Fract =
  result = 0.toRational
  var b = 1 // base
  var n = n
  while n != 0:
    result += n mod base * b
    n = n div base
    b /= base

for base in 2..5:
  let list = collect(newSeq, for n in 1..10: corput(n, base))
  echo "Base $#: ".format(base), list.join(" ")


System.file.stdout|write("Enter a String ");
string = System.file.stdin|readline();


// version 1.1

fun main(args: Array<String>) {
    print("Enter a string : ")
    val s = readLine()!!
    println(s)
    do {
        print("Enter 75000 : ")
        val number = readLine()!!.toInt()
    } while (number != 75000)
}


#!/usr/bin/lasso9

define read_input(prompt::string) => {

	local(string)

	// display prompt
	stdout(#prompt)
	// the following bits wait until the terminal gives you back a line of input
	while(not #string or #string -> size == 0) => {
		#string = file_stdin -> readsomebytes(1024, 1000)
	}
	#string -> replace(bytes('\n'), bytes(''))

	return #string -> asstring

}

local(
	string,
	number
)

// get string
#string = read_input('Enter the string: ')

// get number
#number = integer(read_input('Enter the number: '))

// deliver the result
stdoutnl(#string + ' (' + #string -> type + ') | ' + #number + ' (' + #number -> type + ')')


Input "Enter a string. ";string$
Input "Enter the value 75000.";num


# User input/text, in LIL
write "Enter a string: "
set text [readline]

set num 0
while {[canread] && $num != 75000} {
    write "Enter the number 75000: "
    set num [readline]
}

print $text
print $num


VdC(n)=n=binary(n);sum(i=1,#n,if(n[i],1.>>(#n+1-i)));
VdC(n)=sum(i=1,#binary(n),if(bittest(n,i-1),1.>>i)); \\ Alternate approach
vector(10,n,VdC(n))


Program VanDerCorput;
{$IFDEF FPC}
  {$MODE DELPHI}
{$ELSE}
  {$APPTYPE CONSOLE}
{$ENDIF}

type
  tvdrCallback = procedure (nom,denom: NativeInt);

{ Base=2
function rev2(n,Pot:NativeUint):NativeUint;
var
  r : Nativeint;
begin
  r := 0;
  while Pot > 0 do
  Begin
    r := r shl 1 OR (n AND 1);
    n := n shr 1;
    dec(Pot);
  end;
  rev2 := r;
end;
}

function reverse(n,base,Pot:NativeUint):NativeUint;
var
  r,c : Nativeint;
begin
  r := 0;
//No need to test n> 0 in this special case, n starting in upper half
  while Pot > 0 do
  Begin
    c := n div base;
    r := n+(r-c)*base;
    n := c;
    dec(Pot);
  end;
  reverse := r;
end;

procedure VanDerCorput(base,count:NativeUint;f:tvdrCallback);
//calculates count nominater and denominater of Van der Corput sequence
// to base
var
 Pot,
 denom,nom,
 i : NativeUint;
Begin
  denom := 1;
  Pot := 0;
  while count > 0 do
  Begin
    IF Pot = 0 then
      f(0,1);
    //start in upper half
    i := denom;
    inc(Pot);
    denom := denom *base;

    repeat
      nom := reverse(i,base,Pot);
      IF count > 0 then
        f(nom,denom)
      else
        break;
      inc(i);
      dec(count);
    until i >= denom;
  end;
end;

procedure vdrOutPut(nom,denom: NativeInt);
Begin
  write(nom,'/',denom,'  ');
end;

var
 i : NativeUint;
Begin
  For i := 2 to 5 do
  Begin
    write(' Base ',i:2,' :');
    VanDerCorput(i,9,@vdrOutPut);
    writeln;
  end;
end.


make "input readlist   ; in: string 75000
show map "number? :input  ; [false true]

make "input readword   ; in: 75000
show :input + 123       ; 75123
make "input readword   ; in: string 75000
show :input             ; string 75000


:- object(user_input).

    :- public(test/0).
    test :-
        repeat,
            write('Enter an integer: '),
            read(Integer),
        integer(Integer),
        !,
        repeat,
            write('Enter an atom: '),
            read(Atom),
        atom(Atom),
        !.

:- end_object.


HAI 1.4
I HAS A string
GIMMEH string
I HAS A number
GIMMEH number
BTW converts number input to an integer
MAEK number A NUMBR
KTHXBYE


print('Enter a string: ')
s = io.stdin:read()
print('Enter a number: ')
i = tonumber(io.stdin:read())


sub vdc {
    my @value = shift;
    my $base = shift // 2;
    use integer;
    push @value, $value[-1] / $base while $value[-1] > 0;
    my ($x, $sum) = (1, 0);
    no integer;
    $sum += ($_ % $base) / ($x *= $base) for @value;
    return $sum;
}

for my $base ( 2 .. 5 ) {
    print "base $base: ", join ' ', map { vdc($_, $base) } 0 .. 10;
    print "\n";
}


enum BASE, FRAC, DECIMAL
constant DESC = {"Base","Fraction","Decimal"}

function vdc(integer n, atom base, integer flag)
object res = ""
atom num = 0, denom = 1, digit, g
    while n do
        denom *= base
        digit = remainder(n,base)
        n = floor(n/base)
        if flag=BASE then
            res &= digit+'0'
        else
            num = num*base+digit
        end if
    end while
    if flag=FRAC then
        g = gcd(num,denom)
        return {num/g,denom/g}
    elsif flag=DECIMAL then
        return num/denom
    end if
    return {iff(length(res)=0?"0":"0."&res)}
end function

procedure show_vdc(integer flag, string fmt)
object v
    for i=2 to 5 do
        printf(1,"%s %d: ",{DESC[flag],i})
        for j=0 to 9 do
            v = vdc(j,i,flag)
            if flag=FRAC and v[1]=0 then
                printf(1,"0 ")
            else
                printf(1,fmt,v)
            end if
        end for
        puts(1,"\n")
    end for
end procedure

show_vdc(BASE,"%s ")
show_vdc(FRAC,"%d/%d ")
show_vdc(DECIMAL,"%g ")


Module CheckIt {
      Keyboard "75000"+chr$(13)
      Input "Integer:", A%
      \\ Input erase keyboard buffer, we can't place in first Keyboard keys for second input
      Keyboard  "Hello World"+Chr$(13)
      Input "String:", A$
      Print A%, A$
}
CheckIt


        TITLE User Input

COMMENT !
     User Input ** PDP-10 assembly language (kjx, 2022)
      Assembler: MACRO-10   Operating system: TOPS-20

  This program reads a string (maximum of 80 characters) and
  a decimal number. The number is checked to be 75000. Invalid
  input (like entering characters instead of a decimal number)
  is detected, and an error message is printed in that case.
!

        SEARCH MONSYM,MACSYM
        .REQUIRE SYS:MACREL

        STDAC.                          ;Set standard register names.

STRING: BLOCK 20                        ;20 octal words = 80 characters.
NUMBER: BLOCK 1                         ;1 word for number.

        ;;
        ;; Execution starts here:
        ;;

GO::    RESET%                          ;Initialize process.

        ;; Print prompt:

        HRROI T1,[ASCIZ /Please type a string, 80 chars max.: /]
        PSOUT%

        ;; Read string from terminal:

        HRROI T1,STRING                 ;Pointer to string-buffer.
        MOVEI T2,^D80                   ;80 characters max.
        SETZ  T3                        ;No special ctrl-r prompt.
        RDTTY%                          ;Read from terminal.
          ERJMP ERROR                   ;  On error, go to ERROR.

        ;; Print second prompt:

NUMI:   HRROI T1,[ASCIZ /Please type the decimal number 75000: /]
        PSOUT%

        ;; Input number from terminal:

        MOVEI T1,.PRIIN                 ;Read from terminal.
        MOVEI T3,^D10                   ;Decimal input.
        NIN%                            ;Input number.
          ERJMP ERROR                   ;  On error, go to ERROR.

        ;; Make sure number is actually 75000.

        CAIE  T2,^D75000                ;Compare number...
          JRST [ HRROI T1,[ASCIZ /Number is not 75000! /]
                 PSOUT%                 ;  ...complain and
                 JRST  NUMI ]           ;  try again.
        MOVEM T2,NUMBER                 ;Store number if correct.

        ;; Now print out string and number:

        HRROI T1,STRING                 ;String ptr into T1.
        PSOUT%                          ;Print string.

        MOVEI T1,.PRIOU                 ;Print on standard output.
        MOVE  T2,NUMBER                 ;Load number into T2.
        MOVEI T3,^D10                   ;Decimal output.
        NOUT%                           ;And print the number.
          ERJMP ERROR                   ;  On error, go to ERROR.

        ;; End program:

        HALTF%                          ;Halt program.
        JRST  GO                        ;Allow for 'continue'-command.

        ;;
        ;; The following routine prints out an error message,
        ;; similar to perror() in C:
        ;;

ERROR:  MOVEI T1,.PRIOU                 ;Standard output.
        MOVE  T2,[.FHSLF,,-1]           ;Own program, last error.
        SETZ  T3,                       ;No size-limit on message.
        ERSTR%                          ;Print error-message.
          JFCL                          ;  Ignore errors from ERSTR.
          JFCL                          ;  dito.
        HALTF%                          ;Halt program.
        JRST  GO                        ;Allow for 'continue'-command.

        END GO


printf("String:"); string_value := readline();
printf("Integer: "); int_value := parse(readline());


mystring = InputString["give me a string please"];
myinteger = Input["give me an integer please"];


>> input('Input string: ')
Input string: 'Hello'

ans =

Hello

>> input('Input number: ')
Input number: 75000

ans =

       75000

>> input('Input number, the number will be stored as a string: ','s')
Input number, the number will be stored as a string: 75000

ans =

75000


(scl 6)

(de vdc (N B)
   (default B 2)
   (let (R 0  A 1.0)
      (until (=0 N)
         (inc 'R (* (setq A (/ A B)) (% N B)))
         (setq N (/ N B)) )
      R ) )

(for B (2 3 4)
   (prinl "Base: " B)
   (for N (range 0 9)
      (prinl N ": " (round (vdc N B) 4)) ) )


vdcb: procedure (an) returns (bit (31)); /* 6 July 2012 */
   declare an fixed binary (31);
   declare (n, i) fixed binary (31);
   declare v bit (31) varying;

   n = an; v = ''b;
   do i = 1 by 1 while (n > 0);
      if iand(n, 1) = 1 then v = v || '1'b; else v = v || '0'b;
      n = isrl(n, 1);
   end;
   return (v);
end vdcb;

   declare i fixed binary (31);

   do i = 0 to 10;
      put skip list ('0.' || vdcb(i));
   end;


% vdc( N, Base, Out )
% Out = the Van der Corput representation of N in given Base
vdc( 0, _, [] ).
vdc( N, Base, Out ) :-
    Nr is mod(N, Base),
    Nq is N // Base,
    vdc( Nq, Base, Tmp ),
    Out = [Nr|Tmp].

% Writes every element of a list to stdout; no newlines
write_list( [] ).
write_list( [H|T] ) :-
    write( H ),
    write_list( T ).

% Writes the Nth Van der Corput item.
print_vdc( N, Base ) :-
    vdc( N, Base, Lst ),
    write('0.'),
    write_list( Lst ).
print_vdc( N ) :-
    print_vdc( N, 2 ).

% Prints the first N+1 elements of the Van der Corput
% sequence, each to its own line
print_some( 0, _ ) :-
    write( '0.0' ).
print_some( N, Base ) :-
    M is N - 1,
    print_some( M, Base ),
    nl,
    print_vdc( N, Base ).
print_some( N ) :-
    print_some( N, 2 ).

test :-
   writeln('First 10 members in base 2:'),
   print_some( 9 ),
   nl,
   write('7th member in base 4 (stretch goal) => '),
   print_vdc( 7, 4 ).


string s;
message "write a string: ";
s := readstring;
message s;
message "write a number now: ";
b := scantokens readstring;
if b = 750:
  message "You've got it!"
else:
  message "Sorry..."
fi;
end


"Enter a string" ask
"Enter an integer" ask int


alias askmesomething {
  echo -a You answered: $input(What's your name?, e)
}


MODULE Input EXPORTS Main;

IMPORT IO, Fmt;

VAR string: TEXT;
    number: INTEGER;

BEGIN
  IO.Put("Enter a string: ");
  string := IO.GetLine();
  IO.Put("Enter a number: ");
  number := IO.GetInt();
  IO.Put("You entered: " & string & " and " & Fmt.Int(number) & "\n");
END Input.


Procedure.d nBase(n.i,b.i)
  Define r.d,s.i=1
  While n
    s*b
    r+(Mod(n,b)/s)
    n=Int(n/b)
  Wend
  ProcedureReturn r
EndProcedure

Define.i b,c
OpenConsole("van der Corput - Sequence")
For b=2 To 5
  Print("Base "+Str(b)+": ")
  For c=0 To 9
    Print(StrD(nBase(c,b),5)+~"\t")
  Next
  PrintN("")
Next
Input()


def vdc(n, base=2):
    vdc, denom = 0,1
    while n:
        denom *= base
        n, remainder = divmod(n, base)
        vdc += remainder / denom
    return vdc


  [ $ "bigrat.qky" loadfile ] now!

  [ [] swap
    [ dup while
      base share /mod
      rot join swap
      again ]
    drop ]                   is digits (   n --> [   )

  [ base put
    digits reverse
    dup 0 swap
    witheach
      [ base share rot * + ]
    base take rot size **
    reduce ]                 is corput ( n n --> n/d )

  5 times
    [ say "base "
      i^ 2 + dup echo
      say ":  "
      10 times
        [ i^ over corput
          vulgar$ echo$ sp sp ]
      cr drop ]


TXTINP
 NEW S,N
 WRITE "Enter a string: "
 READ S,!
 WRITE "Enter the number 75000: "
 READ N,!
 KILL S,N
 QUIT


string  = str(input("Enter a string: "))
integer = int(input("Enter an integer: "))


/**
 User input/Text, in Neko
 Tectonics:
   nekoc userinput.neko
   neko userinput
*/

var stdin = $loader.loadprim("[email protected]_stdin", 0)()
var file_read_char = $loader.loadprim("[email protected]_read_char", 1)

/* Read a line from file f into string s returning length without any newline */
var NEWLINE = 10
var readline = function(f, s) {
    var len = 0
    var ch
    while true {
        try ch = file_read_char(f) catch a break;
        if ch == NEWLINE break;
        if $sset(s, len, ch) == null break; else len += 1
    }
    return $ssub(s, 0, len)
}

$print("Enter a line of text, then the number 75000\n")

try {
    var RECL = 132
    var str = $smake(RECL)
    var userstring = readline(stdin, str)
    $print(":", userstring, ":\n")

    var num = $int(readline(stdin, str))
    if num == 75000 $print("Rosetta Code 75000, for the win!\n")
    else $print("Sorry, need 75000\n")
} catch problem $print("Exception: ", problem, "\n")


using System;
using System.Console;

module Input
{
    Main() : void
    {
        Write("Enter a string:");
        _ = ReadLine()

        mutable entry = 0;
        mutable numeric = false;

        do
        {
            Write("Enter 75000:");
            numeric = int.TryParse(ReadLine(), out entry);
        } while ((!numeric) || (entry != 75000))
    }
}


#lang racket
(define (van-der-Corput n base)
  (if (zero? n)
      0
      (let-values ([(q r) (quotient/remainder n base)])
        (/ (+ r (van-der-Corput q base))
           base))))


constant VdC = map { :2("0." ~ .base(2).flip) }, ^Inf;
.say for VdC[^16];


/*REXX program converts an integer (or a range)  ──►  a Van der Corput number in base 2.*/
numeric digits 1000                              /*handle almost anything the user wants*/
parse arg a b .                                  /*obtain the optional arguments from CL*/
if a==''  then parse value  0  10   with   a  b  /*Not specified?  Then use the defaults*/
if b==''  then b= a                              /*assume a  range  for a single number.*/

      do j=a  to b                               /*traipse through the range of numbers.*/
      _= VdC( abs(j) )                           /*convert absolute value of an integer.*/
      leading= substr('-',   2 + sign(j) )       /*if needed,  elide the leading sign.  */
      say leading  ||  _                         /*show number, with leading minus sign?*/
      end   /*j*/
exit                                             /*stick a fork in it,  we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
VdC: procedure;    y= x2b( d2x( arg(1) ) )  + 0  /*convert to  hexadecimal, then binary.*/
     if y==0  then return 0                      /*handle the special case of zero.     */
                   return '.'reverse(y)          /*heavy lifting is performed by REXX.  */


/* NetRexx */
options replace format comments java crossref symbols nobinary

checkVal = 75000
say 'Input a string then the number' checkVal
parse ask inString
parse ask inNumber .

say 'Input string:' inString
say 'Input number:' inNumber
if inNumber == checkVal then do
  say 'Success!  Input number is as requested'
  end
else do
  say 'Failure!  Number' inNumber 'is not' checkVal
  end
return


(print "Enter an integer: ")
(set 'x (read-line))
(print "Enter a string: ")
(set 'y (read-line))


import rdstdin, strutils

let str = readLineFromStdin "Input a string: "
let num = parseInt(readLineFromStdin "Input an integer: ")


10 INPUT "ENTER A STRING: ",STRING$
20 PRINT "YOU ENTERED ";STRING$;"."
30 INPUT "ENTER AN INTEGER: ",INTEGER
40 PRINT "YOU ENTERED";INTEGER;"."


MODULE InputText;
IMPORT
  In,
  Out;
VAR
  i: INTEGER;
  str: ARRAY 512 OF CHAR;
BEGIN
  Out.String("Enter a integer: ");Out.Flush();In.Int(i);
  Out.String("Enter a string: ");Out.Flush();In.String(str);
END InputText.


decimals(4)
for base = 2 to 5
    see "base " + string(base) + " : "
    for number = 0 to 9
        see "" + corput(number, base) + " "
    next
    see nl
next

func corput n, b
     vdc = 0
     denom = 1
     while n
           denom *= b
           rem = n % b
           n = floor(n/b)
           vdc += rem / denom
     end
     return vdc


def vdc(n, base=2)
  str = n.to_s(base).reverse
  str.to_i(base).quo(base ** str.length)
end

(2..5).each do |base|
  puts "Base #{base}: " + Array.new(10){|i| vdc(i,base)}.join(", ")
end


/// Van der Corput sequence for any base, based on C languange example from Wikipedia.
pub fn corput(nth: usize, base: usize) -> f64 {
    let mut n = nth;
    let mut q: f64 = 0.0;
    let mut bk: f64 = 1.0 / (base as f64);

    while n > 0_usize {
      q += ((n % base) as f64)*bk;
      n /= base;
      bk /= base as f64;
    }
    q
}

fn main() {
  for base in 2_usize..=5_usize {
    print!("Base {}:", base);
    for i in 1_usize..=10_usize {
      let c = corput(i, base);
      print!("  {:.6}", c)
    }
    println!("");
  }
}


object VanDerCorput extends App {
    def compute(n: Int, base: Int = 2) =
        Iterator.from(0).
            scanLeft(1)((a, _) => a * base).
            map(b => (n - 1) / b -> b).
            takeWhile(_._1 != 0).
            foldLeft(0d)((a, b) => a + (b._1 % base).toDouble / b._2 / base)

    val n = scala.io.StdIn.readInt
    val b = scala.io.StdIn.readInt
    (1 to n).foreach(x => println(compute(x, b)))
}


use IO;

bundle Default {
  class Hello {
    function : Main(args : String[]) ~ Nil {
      string := Console->GetInstance()->ReadString();
      string->PrintLine();

      number := Console->GetInstance()->ReadString()->ToInt();
      number->PrintLine();
    }
  }
}


print_string "Enter a string: ";
let str = read_line () in
  print_string "Enter an integer: ";
  let num = read_int () in
    Printf.printf "%s%d\n" str num


% read a string ("s")
s = input("Enter a string: ", "s");

% read a GNU Octave expression, which is evaluated; e.g.
% 5/7 gives 0.71429
i = input("Enter an expression: ");

% parse the input for an integer
printf("Enter an integer: ");
ri = scanf("%d");

% show the values
disp(s);
disp(i);
disp(ri);


$ include "seed7_05.s7i";
  include "float.s7i";

const func float: vdc (in var integer: number, in integer: base) is func
  result
    var float: vdc is 0.0;
  local
    var integer: denom is 1;
    var integer: remainder is 0;
  begin
    while number <> 0 do
      denom *:= base;
      remainder := number rem base;
      number := number div base;
      vdc +:= flt(remainder) / flt(denom);
    end while;
  end func;

const proc: main is func
  local
    var integer: base is 0;
    var integer: number is 0;
  begin
    for base range 2 to 5 do
      writeln;
      writeln("Base " <& base);
      for number range 0 to 9 do
        write(vdc(number, base) digits 6 <& " ");
      end for;
      writeln;
    end for;
  end func;


func vdc(value, base=2) {
    while (value[-1] > 0) {
        value.append(value[-1] / base -> int)
    }
    var (x, sum) = (1, 0)
    value.each { |i|
        sum += ((i % base) / (x *= base))
    }
    return sum
}

for base in (2..5) {
    var seq = 10.of {|i| vdc([i], base) }
    "base %d: %s\n".printf(base, seq.map{|n| "%.4f" % n}.join(', '))
}


import: console

: testInput{
| s n |
   System.Console askln ->s
   while (System.Console askln asInteger dup ->n isNull) [ "Not an integer" println ]

   System.Out "Received : " << s << " and " << n << cr ;


declare
  StdIn = {New class $ from Open.file Open.text end init(name:stdin)}
  StringInput
  Num = {NewCell 0}
in
  {System.printInfo "Enter a string: "}
  StringInput = {StdIn getS($)}

  for until:@Num == 75000 do
     {System.printInfo "Enter 75000: "}
     Line = {StdIn getS($)}
  in
     Num := try {String.toInt Line} catch _ then 0 end
  end


program UserInput(input, output);
var i : Integer;
    s : String;
begin
 write('Enter an integer: ');
 readln(i);
 write('Enter a string: ');
 readln(s)
end.


func vanDerCorput(n: Int, base: Int, num: inout Int, denom: inout Int) {
  var n = n, p = 0, q = 1

  while n != 0 {
    p = p * base + (n % base)
    q *= base
    n /= base
  }

  num = p
  denom = q

  while p != 0 {
    n = p
    p = q % p
    q = n
  }

  num /= q
  denom /= q
}

var num = 0
var denom = 0

for base in 2...5 {
  print("base \(base): 0 ", terminator: "")

  for n in 1..<10 {
    vanDerCorput(n: n, base: base, num: &num, denom: &denom)

    print("\(num)/\(denom) ", terminator: "")
  }

  print()
}


proc digitReverse {n {base 2}} {
    set n [expr {[set neg [expr {$n < 0}]] ? -$n : $n}]
    set result 0.0
    set bit [expr {1.0 / $base}]
    for {} {$n > 0} {set n [expr {$n / $base}]} {
	set result [expr {$result + $bit * ($n % $base)}]
	set bit [expr {$bit / $base}]
    }
    return [expr {$neg ? -$result : $result}]
}


Private Function vdc(ByVal n As Integer, BASE As Variant) As Variant
    Dim res As String
    Dim digit As Integer, g As Integer, denom As Integer
    denom = 1
    Do While n
        denom = denom * BASE
        digit = n Mod BASE
        n = n \ BASE
        res = res & CStr(digit) '+ "0"
    Loop
    vdc = IIf(Len(res) = 0, "0", "0." & res)
End Function

Public Sub show_vdc()
    Dim v As Variant, j As Integer
    For i = 2 To 5
        Debug.Print "Base "; i; ": ";
        For j = 0 To 9
            v = vdc(j, i)
            Debug.Print v; " ";
        Next j
        Debug.Print
    Next i
End Sub


print "Enter a string: ";
my $string = <>;
print "Enter an integer: ";
my $integer = <>;


?prompt_string("Enter any string:")
?prompt_number("Enter the number 75000:",{75000,75000})


#!/usr/bin/php
<?php
$string = fgets(STDIN);
$integer = (int) fgets(STDIN);


main =>
  print("Enter a string: "),
  String = read_line(),
  print("Enter a number: "),
  Number = read_int(),
  println([string=String,number=Number]).


(in NIL  # Guarantee reading from standard input
   (let (Str (read)  Num (read))
      (prinl "The string is: \"" Str "\"")
      (prinl "The number is: " Num) ) )


'http://rosettacode.org/wiki/Van_der_Corput_sequence
'Van der Corput Sequence fucntion call = VanVanDerCorput(number,base)

Base2 = "0" : Base3 = "0" : Base4 = "0" : Base5 = "0"
Base6 = "0" : Base7 = "0" : Base8 = "0" : Base9 = "0"

l = 1
h = 1
Do Until l = 9
	'Set h to the value of l after each function call
	'as it sets it to 0 - see lines 37 to 40.
	Base2 = Base2 & ", " & VanDerCorput(h,2) : h = l
	Base3 = Base3 & ", " & VanDerCorput(h,3) : h = l
	Base4 = Base4 & ", " & VanDerCorput(h,4) : h = l
	Base5 = Base5 & ", " & VanDerCorput(h,5) : h = l
	Base6 = Base6 & ", " & VanDerCorput(h,6) : h = l
	l = l + 1
Loop

WScript.Echo "Base 2: " & Base2
WScript.Echo "Base 3: " & Base3
WScript.Echo "Base 4: " & Base4
WScript.Echo "Base 5: " & Base5
WScript.Echo "Base 6: " & Base6

'Van der Corput Sequence
Function VanDerCorput(n,b)
	k = RevString(Dec2BaseN(n,b))
	For i = 1 To Len(k)
		VanDerCorput = VanDerCorput + (CLng(Mid(k,i,1)) * b^-i)
	Next
End Function

'Decimal to Base N Conversion
Function Dec2BaseN(q,c)
	Dec2BaseN = ""
	Do Until q = 0
		Dec2BaseN = CStr(q Mod c) & Dec2BaseN
		q = Int(q / c)
	Loop
End Function

'Reverse String
Function RevString(s)
	For j = Len(s) To 1 Step -1
		RevString = RevString & Mid(s,j,1)
	Next
End Function


Module Module1

    Function ToBase(n As Integer, b As Integer) As String
        Dim result = ""
        If b < 2 Or b > 16 Then
            Throw New ArgumentException("The base is out of range")
        End If

        Do
            Dim remainder = n Mod b
            result = "0123456789ABCDEF"(remainder) + result
            n = n \ b
        Loop While n > 0

        Return result
    End Function

    Sub Main()
        For b = 2 To 5
            Console.WriteLine("Base = {0}", b)
            For i = 0 To 12
                Dim s = "." + ToBase(i, b)
                Console.Write("{0,6} ", s)
            Next
            Console.WriteLine()
            Console.WriteLine()
        Next
    End Sub

End Module


fn v2(nn u32) f64 {
    mut n:=nn
    mut r := f64(0)
    mut p := .5
    for n > 0 {
        if n&1 == 1 {
            r += p
        }
        p *= .5
        n >>= 1
    }
    return r
}

fn new_v(base u32) fn(u32) f64 {
    invb := 1 / f64(base)
    return fn[base,invb](nn u32) f64 {
        mut n:=nn
        mut r := f64(0)
        mut p := invb
        for n > 0 {
            r += p * f64(n%base)
            p *= invb
            n /= base
        }
        return r
    }
}

fn main() {
    println("Base 2:")
    for i := u32(0); i < 10; i++ {
        println('$i ${v2(i)}')
    }
    println("Base 3:")
    v3 := new_v(3)
    for i := u32(0); i < 10; i++ {
        println('$i ${v3(i)}')
    }
}


var v2 = Fn.new { |n|
    var p = 0.5
    var r = 0
    while (n > 0) {
        if (n%2 == 1) r = r + p
        p = p / 2
        n = (n/2).floor
    }
    return r
}

var newV = Fn.new { |base|
    var invb = 1 / base
    return Fn.new { |n|
        var p = invb
        var r = 0
        while (n > 0) {
            r = r + p*(n%base)
            p = p * invb
            n = (n/base).floor
        }
        return r
    }
}

System.print("Base 2:")
for (i in 0..9) System.print("%(i) -> %(v2.call(i))")

System.print("\nBase 3:")
var v3 = newV.call(3)
for (i in 0..9) System.print("%(i) -> %(v3.call(i))")


int main(){
   write("Enter a String: ");
   string str = Stdio.stdin->gets();
   write("Enter 75000: ");
   int num = Stdio.stdin->gets();
}


declare s character (100) varying;
declare k fixed decimal (15);

put ('please type a string:');
get edit (s) (L);
put skip list (s);

put skip list ('please type the integer 75000');
get list (k);
put skip list (k);
put skip list ('Thanks');


To run:
Start up.
Demonstrate input.
Wait for the escape key.
Shut down.

To demonstrate input:
Write "Enter a string: " to the console without advancing.
Read a string from the console.
Write "Enter a number: " to the console without advancing.
Read a number from the console.
\Now show the input values
Write "The string: " then the string to the console.
Write "The number: " then the number to the console.


;;; Setup item reader
lvars itemrep = incharitem(charin);
lvars s, c, j = 0;
;;; read chars up to a newline and put them on the stack
while (charin() ->> c) /= `\n` do j + 1 -> j ; c endwhile;
;;; build the string
consstring(j) -> s;
;;; read the integer
lvars i = itemrep();


%open stdin for reading (and name the channel "kbd"):
/kbd (%stdin) (r) file def
%make ten-char buffer to read string into:
/buf (..........) def
%read string into buffer:
kbd buf readline


include c:\cxpl\codes;  \intrinsic 'code' declarations

func real VdC(N);       \Return Nth term of van der Corput sequence in base 2
int  N;
real V, U;
[V:= 0.0;  U:= 0.5;
repeat  N:= N/2;
        if rem(0) then V:= V+U;
        U:= U/2.0;
until   N=0;
return V;
];

int N;
for N:= 0 to 10-1 do
        [IntOut(0, N);  RlOut(0, VdC(N));  CrLf(0)]


fcn vdc(n,base=2){
   vdc:=0.0; denom:=1;
   while(n){ reg remainder;
      denom *= base;
      n, remainder = n.divr(base);
      vdc += (remainder.toFloat() / denom);
   }
   vdc
}


$string = Read-Host "Input a string"
[int]$number = Read-Host "Input a number"


If OpenConsole()
  ; Declare a string and a integer to be used
  Define txt.s, num.i

  Print("Enter a string: ")
  txt=Input()

  Repeat
    Print("Enter the number 75000: ")
    num=Val(Input()) ; Converts the Input to a Value with Val()
  Until num=75000
  ; Check that the user really gives us 75000!

  Print("You made it!")
  Delay(3000): CloseConsole()
EndIf


$ "Please enter a string: " input
say 'You entered: "' echo$ say '"' cr cr

$ "Please enter an integer: " input
trim reverse trim reverse
$->n iff
  [ say "You entered: " echo cr ]
else
  [ say "That was not an integer." cr
    drop ]


stringval <- readline("String: ")
intval <- as.integer(readline("Integer: "))


#lang racket
(printf "Input a string: ")
(define s (read-line))
(printf "You entered: ~a\n" s)

(printf "Input a number: ")
(define m (or (string->number (read-line))
              (error "I said a number!")))
(printf "You entered: ~a\n" m)

;; alternatively, use the generic `read'
(printf "Input a number: ")
(define n (read))
(unless (number? n) (error "I said a number!"))
(printf "You entered: ~a\n" n)


my $str = prompt("Enter a string: ");
my $int = prompt("Enter a integer: ");


import util::IDE;
public void InputConsole(){
    x = "";
    createConsole("Input Console",
                  "Welcome to the Input Console\nInput\> ",
                  str (str inp) {x = "<inp == "75000" ? "You entered 75000" : "You entered a string">";
                 		 return "<x>\n<inp>\nInput\>";});
}


'Input a string: '   print expect as str
'Input an integer: ' print expect 0 prefer as num


rebol [
	Title: "Textual User Input"
	URL: http://rosettacode.org/wiki/User_Input_-_text
]

s: n: ""

; Because I have several things to check for, I've made a function to
; handle it. Note the question mark in the function name, this convention
; is often used in Forth to indicate test of some sort.

valid?: func [s n][
	error? try [n: to-integer n] ; Ignore error if conversion fails.
	all [0 < length? s  75000 = n]]

; I don't want to give up until I've gotten something useful, so I
; loop until the user enters valid data.

while [not valid? s n][
	print "Please enter a string, and the number 75000:"
	s: ask "string: "
	n: ask "number: "
]

; It always pays to be polite...

print rejoin [ "Thank you. Your string was '" s "'."]


n: ask "Please enter # 75000: " str: ask "Please enter any string: "


:example ("-)
  'Enter_a_string:_ s:put s:get s:keep
  [ 'Enter_75000:_ s:put s:get-word s:to-number nl #75000 eq? ] until
  'Your_string_was:_'%s'\n s:format s:put ;


see "Enter a string : " give s
see "Enter an integer : " give i
see "String  = " + s + nl
see "Integer = " + i + nl


input string "Enter string:"
set "$str" to "input"
input string "Enter number:"
set "number" to "input"
[ "You entered:"
[ "&$str&"
[ "&number&"
end


print "Enter a string: "
s = gets
printf "Enter an integer: "
i = gets.to_i   # If string entered, will return zero
printf "Enter a real number: "
f = Float(gets) rescue nil   # converts a floating point number or returns nil
puts "String  = #{s}"
puts "Integer = #{i}"
puts "Float   = #{f}"


use std::io::{self, Write};
use std::fmt::Display;
use std::process;

fn main() {
    let s = grab_input("Give me a string")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)));

    println!("You entered: {}", s.trim());

    let n: i32 = grab_input("Give me an integer")
        .unwrap_or_else(|e| exit_err(&e, e.raw_os_error().unwrap_or(-1)))
        .trim()
        .parse()
        .unwrap_or_else(|e| exit_err(&e, 2));

    println!("You entered: {}", n);
}

fn grab_input(msg: &str) -> io::Result<String> {
    let mut buf = String::new();
    print!("{}: ", msg);
    try!(io::stdout().flush());

    try!(io::stdin().read_line(&mut buf));
    Ok(buf)
}

fn exit_err<T: Display>(msg: T, code: i32) -> ! {
    let _ = writeln!(&mut io::stderr(), "Error: {}", msg);
    process::exit(code)
}


print("Enter a number: ")
val i=Console.readLong  // Task says to enter 75000
print("Enter a string: ")
val s=Console.readLine


(define str (read))
(define num (read))
(display "String = ") (display str)
(display "Integer = ") (display num)


$ include "seed7_05.s7i";

const proc: main is func
  local
    var integer: integer_input is 0;
    var string: string_input is "";
  begin
    write("Enter an integer: ");
    readln(integer_input);
    write("Enter a string: ");
    readln(string_input);
  end func;


var s = read(String);
var i = read(Number);    # auto-conversion to a number


print: (query: 'Enter a String: ').
[| n |
  n: (Integer readFrom: (query: 'Enter an Integer: ')).
  (n is: Integer)
    ifTrue: [print: n]
    ifFalse: [inform: 'Not an integer: ' ; n printString]
] do.


'Enter a number: ' display.
a := stdin nextLine asInteger.

'Enter a string: ' display.
b := stdin nextLine.


INPUT "Enter a string.":a$
INPUT "Enter the value 75000.":n


     output = "Enter a string:"
     str = trim(input)
     output = "Enter an integer:"
     int = trim(input)
     output = "String: " str " Integer: " int
end


text = #.input("Input a string")
number = #.val(#.input("Input a number"))


print "Enter a string: ";
let val str = valOf (TextIO.inputLine TextIO.stdIn) in (* note: this keeps the trailing newline *)
  print "Enter an integer: ";
  let val num = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) in
    print (str ^ Int.toString num ^ "\n")
  end
end


print("Enter a string: ", terminator: "")
if let str = readLine() {
  print(str)
}


set str [gets stdin]
set num [gets stdin]


  :Input "Enter a string:",Str1
  :Prompt i
  :If(i ≠ 75000): Then
  :Disp "That isn't 75000"
  :Else
  :Stop


Prgm
  InputStr "Enter a string", s
  Loop
    Prompt integer
    If integer ≠ 75000 Then
      Disp "That wasn't 75000."
    Else
      Exit
    EndIf
  EndLoop
EndPrgm


needs readline
." Enter a string: " readline is-data the-string
." Enter a number: " readline >number [ ." Not a number!" drop 0 ] ifFalse is-data the-number

the-string type cr
the-number . cr


$$ MODE TUSCRIPT
LOOP
ASK "Enter a string": str=""
ASK "Enter an integer": int=""
IF (int=='digits') THEN
PRINT "int=",int," str=",str
EXIT
ELSE
PRINT/ERROR int," is not an integer"
CYCLE
ENDIF
ENDLOOP


#!/bin/sh

read string
read integer
read -p 'Enter a number: ' number
echo "The number is $number"


#
# user input
#

# in ursa, the type of data expected must be specified
decl string str
decl int i

out "input a string: " console
set str (in string console)
out "input an int:   " console
set i (in int console)

out "you entered " str " and " i endl console


Public Sub text()
    Debug.Print InputBox("Input a string")
    Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long")
End Sub


Get_Input(1, "Enter a string: ")
#2 = Get_Num("Enter a number: ")


Dim i As Integer
Console.WriteLine("Enter an Integer")
i = Console.ReadLine()


import os

fn main() {
    s := os.input('Enter string').int()
    if s == 75000 {
        println('good')
    } else {
        println('bad')
    }
}


import os
import strconv

fn main() {
    s := strconv.atoi(os.input('Enter string')) ?
    if s == 75000 {
        println('good')
    } else {
        println('bad $s')
    }
}


print 1 "Enter a string."
input string$
print 1 "Enter an integer."
input integer


import "io" for Stdin, Stdout

var string
while (true) {
    System.write("Enter a string : ")
    Stdout.flush()
    string = Stdin.readLine()
    if (string.count == 0) {
        System.print("String cannot be empty, try again.")
    } else {
        break
    }
}

var number
while (true) {
    System.write("Enter a number : ")
    Stdout.flush()
    number = Num.fromString(Stdin.readLine())
    if (!number || !number.isInteger) {
        System.print("Please enter a vaid integer, try again.")
    } else {
        break
    }
}

System.print("\nYou entered:")
System.print("  string: %(string)")
System.print("  number: %(number)")


(display "Enter a string: ")
(define s (read-line))
(display "Yes, ")
(write s)
(display " is a string.") ;; no need to verify, because READ-LINE has to return a string
(newline)
(display "Now enter the integer 75000: ")
(define n (read))
(display
    (cond
        ((not (integerp n))
            "That's not even an integer." )
        ((/= n 75000)
            "That is not the integer 75000." )
        (t
            "Yes, that is the integer 75000." ) ) )


string  0;              \use zero-terminated strings, instead of MSb terminated
include c:\cxpl\codes;
int     I;
char    Name(128);      \the keyboard buffer limits input to 128 characters

[Text(0, "What's your name? ");
I:= 0;
loop    [Name(I):= ChIn(0);                     \buffered keyboard input
        if Name(I) = $0D\CR\ then quit;         \Carriage Return = Enter key
        I:= I+1;
        ];
Name(I):= 0;                                    \terminate string
Text(0, "Howdy "); Text(0, Name); Text(0, "! Now please enter ^"75000^": ");
IntOut(0, IntIn(0));  CrLf(0);                  \echo the number
]


str:=ask("Gimmie a string: ");
n:=ask("Type 75000: ").toInt();


10 INPUT "Enter a string:"; s$
20 INPUT "Enter a number: "; n


F unicode_code(ch)
   R ‘U+’hex(ch.code).zfill(4)

F utf8hex(ch)
   R ch.encode(‘utf-8’).map(c -> hex(c)).join(‘ ’)

print(‘#<11 #<15 #<15’.format(‘Character’, ‘Unicode’, ‘UTF-8 encoding (hex)’))
V chars = [‘A’, ‘ö’, ‘Ж’, ‘€’]
L(char) chars
   print(‘#<11 #<15 #<15’.format(char, unicode_code(char), utf8hex(char)))


hex \ so bytes print nicely

[
  "\u0041",
  "\u00F6",
  "\u0416",
  "\u20AC"
]
\ add the 0x1D11E one; the '\u' string notation requires four hex digits
  "" 1D11E s:+ a:push

\ for each test, print it out and its bytes:
(
  dup . space
  b:new
  ( . space drop ) b:each
  cr
) a:each! drop

cr
\ now the inverse:
[
  [41],
  [C3,B6],
  [D0,96],
  [E2,82,AC],
  [$F0,9D,84,9E]
]

(
  dup . space
  b:new >s  .  cr
) a:each! drop

bye


TYPE Unicode=[BYTE bc1,bc2,bc3]
BYTE ARRAY hex=['0 '1 '2 '3 '4 '5 '6 '7 '8 '9 'A 'B 'C 'D 'E 'F]

BYTE FUNC DecodeHex(CHAR c)
  BYTE i

  FOR i=0 TO 15
  DO
    IF c=hex(i) THEN
      RETURN (i)
    FI
  OD
  Break()
RETURN (255)

BYTE FUNC DecodeHex2(CHAR c1,c2)
  BYTE h1,h2,res

  h1=DecodeHex(c1)
  h2=DecodeHex(c2)
  res=(h1 LSH 4)%h2
RETURN (res)

PROC ValUnicode(CHAR ARRAY s Unicode POINTER u)
  BYTE i,len

  len=s(0)
  IF len<6 AND len>8 THEN Break() FI
  IF s(1)#'U OR s(2)#'+ THEN Break() FI

  IF len=6 THEN
    u.bc1=0
  ELSEIF len=7 THEN
    u.bc1=DecodeHex(s(3))
    IF u.bc1>$10 THEN Break() FI
  ELSE
    u.bc1=DecodeHex2(s(3),s(4))
  FI
  u.bc2=DecodeHex2(s(len-3),s(len-2))
  u.bc3=DecodeHex2(s(len-1),s(len))
RETURN

PROC PrintHex2(BYTE x)
  Put(hex(x RSH 4))
  Put(hex(x&$0F))
RETURN

PROC StrUnicode(Unicode POINTER u)
  Print("U+")
  IF u.bc1>$F THEN
    PrintHex2(u.bc1)
  ELSEIF u.bc1>0 THEN
    Put(hex(u.bc1))
  FI
  PrintHex2(u.bc2)
  PrintHex2(u.bc3)
RETURN

PROC PrintArray(BYTE ARRAY a BYTE len)
  BYTE i

  Put('[)
  FOR i=0 TO len-1
  DO
    IF i>0 THEN Put(32 )FI
    PrintHex2(a(i))
  OD
  Put('])
RETURN

PROC Encode(Unicode POINTER u BYTE ARRAY buf BYTE POINTER len)
  IF u.bc1>0 THEN
    len^=4
    buf(0)=$F0 % (u.bc1 RSH 2)
    buf(1)=$80 % ((u.bc1 & $03) LSH 4) % (u.bc2 RSH 4)
    buf(2)=$80 % ((u.bc2 & $0F) LSH 2) % (u.bc3 RSH 6)
    buf(3)=$80 % (u.bc3 & $3F)
  ELSEIF u.bc2>=$08 THEN
    len^=3
    buf(0)=$E0 % (u.bc2 RSH 4)
    buf(1)=$80 % ((u.bc2 & $0F) LSH 2) % (u.bc3 RSH 6)
    buf(2)=$80 % (u.bc3 & $3F)
  ELSEIF u.bc2>0 OR u.bc3>=$80 THEN
    len^=2
    buf(0)=$C0 % (u.bc2 LSH 2) % (u.bc3 RSH 6)
    buf(1)=$80 % (u.bc3 & $3F)
  ELSE
    len^=1
    buf(0)=u.bc3
  FI
RETURN

PROC Decode(BYTE ARRAY buf BYTE len Unicode POINTER u)
  IF len=1 THEN
    u.bc1=0
    u.bc2=0
    u.bc3=buf(0)
  ELSEIF len=2 THEN
    u.bc1=0
    u.bc2=(buf(0) & $1F) RSH 2
    u.bc3=(buf(0) LSH 6) % (buf(1) & $3F)
  ELSEIF len=3 THEN
    u.bc1=0
    u.bc2=(buf(0) LSH 4) % ((buf(1) & $3F) RSH 2)
    u.bc3=(buf(1) LSH 6) % (buf(2) & $3F)
  ELSEIF len=4 THEN
    u.bc1=((buf(0) & $07) LSH 2) % ((buf(1) & $3F) RSH 4)
    u.bc2=(buf(1) LSH 4) % ((buf(2) & $3F) RSH 2)
    u.bc3=((buf(2) & $03) LSH 6) % (buf(3) & $3F)
  ELSE
    Break()
  FI
RETURN

PROC Main()
  DEFINE PTR="CARD"
  DEFINE COUNT="11"
  PTR ARRAY case(COUNT)
  Unicode uni,res
  BYTE ARRAY buf(4)
  BYTE i,len

  case(0)="U+0041"
  case(1)="U+00F6"
  case(2)="U+0416"
  case(3)="U+20AC"
  case(4)="U+1D11E"
  case(5)="U+0024"
  case(6)="U+00A2"
  case(7)="U+0939"
  case(8)="U+20AC"
  case(9)="U+D55C"
  case(10)="U+10348"

  FOR i=0 TO COUNT-1
  DO
    IF i=0 THEN
      PrintE("From RosettaCode:")
    ELSEIF i=5 THEN
      PutE() PrintE("From Wikipedia:")
    FI
    ValUnicode(case(i),uni)
    Encode(uni,buf,@len)
    Decode(buf,len,res)

    StrUnicode(uni) Print(" -> ")
    PrintArray(buf,len) Print(" -> ")
    StrUnicode(res) PutE()
  OD
RETURN


with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
with Ada.Integer_Text_IO;
with Ada.Text_IO;
with Ada.Wide_Wide_Text_IO;

procedure UTF8_Encode_And_Decode
is
   package TIO renames Ada.Text_IO;
   package WWTIO renames Ada.Wide_Wide_Text_IO;
   package WWS renames Ada.Strings.UTF_Encoding.Wide_Wide_Strings;

   function To_Hex
     (i : in Integer;
      width : in Natural := 0;
      fill : in Character := '0') return String
   is
      holder : String(1 .. 20);
   begin
      Ada.Integer_Text_IO.Put(holder, i, 16);
      declare
         hex : constant String := holder(Index(holder, "#")+1 .. holder'Last-1);
         filled : String := Natural'Max(width, hex'Length) * fill;
      begin
         filled(filled'Last - hex'Length + 1 .. filled'Last) := hex;
         return filled;
      end;
   end To_Hex;

   input : constant Wide_Wide_String := "AöЖ€𝄞";
begin
   TIO.Put_Line("Character   Unicode    UTF-8 encoding (hex)");
   TIO.Put_Line(43 * '-');
   for WWC of input loop
      WWTIO.Put(WWC & "           ");
      declare
         filled : String := 11 * ' ';
         unicode : constant String := "U+" & To_Hex(Wide_Wide_Character'Pos(WWC), width => 4);
         utf8_string : constant String := WWS.Encode((1 => WWC));
      begin
         filled(filled'First .. filled'First + unicode'Length - 1) := unicode;
         TIO.Put(filled);
         for C of utf8_string loop
            TIO.Put(To_Hex(Character'Pos(C)) & " ");
         end loop;
         TIO.New_Line;
      end;
   end loop;
end UTF8_Encode_And_Decode;