June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,14 @@
;; Project : Associative array/Iteration
;; Date : 2018/03/08
;; Author : Gal Zsolt [~ CalmoSoft ~]
;; Email : <calmosoft@gmail.com>
(setf x (make-array '(3 2)
:initial-contents '(("hello" 13 ) ("world" 31) ("!" 71))))
(setf xlen (array-dimensions x))
(setf len (car xlen))
(dotimes (n len)
(terpri)
(format t "~a" (aref x n 0))
(format t "~a" " : ")
(format t "~a" (aref x n 1)))

View file

@ -2,7 +2,7 @@ import system'collections.
import system'routines.
import extensions.
program =
public program =
[
// 1. Create
var aMap := Dictionary new.
@ -14,5 +14,5 @@ program =
// Enumerate
aMap forEach
(:aKeyValue)[ console printLine(aKeyValue key," : ",aKeyValue) ].
(:aKeyValue)[ console printLine(aKeyValue key," : ",aKeyValue value) ].
].

View file

@ -1,19 +1,19 @@
mydict = [ "hello"=>13, "world"=>31, "!"=>71 ]
dict = Dict("hello" => 13, "world" => 31, "!" => 71)
# applying a function to key-value pairs:
map(println, mydict);
foreach(println, dict)
# iterating over key-value pairs:
for (key,value) in mydict
println("key = $key, value = $value")
for (key, value) in dict
println("dict[$key] = $value")
end
# iterating over keys:
for key in keys(mydict)
println("key = $key")
for key in keys(dict)
@show key
end
# iterating over values:
for value in values(mydict)
println("value = $value")
for value in values(dict)
@show value
end

View file

@ -4,6 +4,11 @@ for %pairs.kv -> $k, $v {
say "(k,v) = ($k, $v)";
}
# Stable order
for %pairs.sort(*.value)>>.kv -> ($k, $v) {
say "(k,v) = ($k, $v)";
}
{ say "$^a => $^b" } for %pairs.kv;
say "key = $_" for %pairs.keys;

View file

@ -0,0 +1,9 @@
# Project : Associative array/Iteration
# Date : 2017/10/22
# Author : Gal Zsolt (~ CalmoSoft ~)
# Email : <calmosoft@gmail.com>
lst = [["hello", 13], ["world", 31], ["!", 71]]
for n = 1 to len(lst)
see lst[n][1] + " : " + lst[n][2] + nl
next