September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -1,4 +1,27 @@
{{omit From|ACL2}}
{{omit From|Ada}}
{{omit from|AmigaE}}
{{omit from|AWK}}
{{omit from|ALGOL 68}}
{{omit from|C}}
{{omit from|C++}}
{{omit from|D}}
{{omit from|Delphi}}
{{omit from|Fortran}}
{{omit from|Free Pascal}}
{{omit from|GUISS}}
{{omit from|Java}}
{{omit from|Lily}}
{{omit from|Locomotive Basic}}
{{omit from|Metafont}}
{{omit from|NetRexx}}
{{omit from|Octave}}
{{omit from|Pascal}}
{{omit from|PureBasic}}
{{omit from|Rust}}
{{omit from|Swift}}
{{omit from|zkl}}
{{omit from|ZX Spectrum Basic}}
;Task:
Create a variable with a user-defined name.

View file

@ -0,0 +1,5 @@
is{ t ⎕this,'←t' } ⍝⍝ the 'Slick Willie' function ;)
'test' is 2 3
test
1 1 1 2 1 3
2 1 2 2 2 3

View file

@ -1,24 +1,22 @@
import system'dynamic.
import extensions.
import system'dynamic;
import extensions;
class TestClass
{
object theVariables.
object theVariables;
constructor new
[
theVariables := DynamicStruct new.
]
constructor()
{
theVariables := new DynamicStruct()
}
eval
[
subject varRef := Signature new literal:(console write:"Enter the variable name:"; readLine).
theVariables~varRef set:42.
closure()
{
auto varRef := new MessageName(console.write:"Enter the variable name:".readLine());
mixin varRef(theVariables).prop := 42;
var v := theVariables~varRef get.
console printLine(varRef literal,"=",theVariables~varRef get); readChar.
]
console.printLine(varRef.Printable,"=",mixin varRef(theVariables).get).readChar()
}
}
program = TestClass new.
public program = new TestClass();

View file

@ -0,0 +1,71 @@
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
func check(err error) {
if err != nil {
log.Fatal(err)
}
}
func main() {
scanner := bufio.NewScanner(os.Stdin)
n := 0
for n < 1 || n > 5 {
fmt.Print("How many integer variables do you want to create (max 5) : ")
scanner.Scan()
n, _ = strconv.Atoi(scanner.Text())
check(scanner.Err())
}
vars := make(map[string]int)
fmt.Println("OK, enter the variable names and their values, below")
for i := 1; i <= n; {
fmt.Println("\n Variable", i)
fmt.Print(" Name : ")
scanner.Scan()
name := scanner.Text()
check(scanner.Err())
if _, ok := vars[name]; ok {
fmt.Println(" Sorry, you've already created a variable of that name, try again")
continue
}
var value int
var err error
for {
fmt.Print(" Value : ")
scanner.Scan()
value, err = strconv.Atoi(scanner.Text())
check(scanner.Err())
if err != nil {
fmt.Println(" Not a valid integer, try again")
} else {
break
}
}
vars[name] = value
i++
}
fmt.Println("\nEnter q to quit")
for {
fmt.Print("\nWhich variable do you want to inspect : ")
scanner.Scan()
name := scanner.Text()
check(scanner.Err())
if s := strings.ToLower(name); s == "q" {
return
}
v, ok := vars[name]
if !ok {
fmt.Println("Sorry there's no variable of that name, try again")
} else {
fmt.Println("It's value is", v)
}
}
}