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

@ -0,0 +1,14 @@
:- initialization(main).
main :-
sum(b=2,output=Output,a=1),
writeln(Output).
sum(A1,B1,C1) :-
named_args([A1,B1,C1],[a=A,b=B,output=Output]),
Output is A + B.
named_args([],_).
named_args([A|B],C) :-
member(A,C),
named_args(B,C).

View file

@ -1,4 +1,4 @@
func isGreater(x x:Int, thanY y:Int) -> Bool {
return x > y
func greet(person: String, hometown: String) -> String {
return "Hello \(person)! Glad you could visit from \(hometown)."
}
assert(isGreater(x: 5, thanY: 10) == false)
print(greet(person: "Bill", hometown: "Cupertino"))

View file

@ -1,4 +1,4 @@
func isGreater(x:Int, _ y:Int) -> Bool {
return x > y
func greet(person: String, from hometown: String) -> String {
return "Hello \(person)! Glad you could visit from \(hometown)."
}
assert(isGreater(5, 10) == false)
print(greet(person: "Bill", from: "Cupertino"))

View file

@ -0,0 +1,4 @@
func greet(_ person: String, _ hometown: String) -> String {
return "Hello \(person)! Glad you could visit from \(hometown)."
}
print(greet("Bill", "Cupertino"))

View file

@ -0,0 +1,4 @@
func greet(person: String, from hometown: String = "Cupertino") -> String {
return "Hello \(person)! Glad you could visit from \(hometown)."
}
print(greet(person: "Bill"))

View file

@ -0,0 +1,17 @@
Public Function timedelta(Optional weeks As Integer = 0, Optional days As Integer = 0, _
Optional hours As Integer = 0, Optional minutes As Integer = 0, Optional seconds As Integer = 0, _
Optional milliseconds As Integer = 0, Optional microseconds As Integer = 0) As Variant
End Function
Public Sub main()
'-- can be invoked as:
fourdays = timedelta(days:=4)
'-- fourdays = timedelta(0,4) '-- equivalent
'-- **NB** a plain '=' is a very different thing
oneday = timedelta(days = 1) '-- equivalent to timedelta([weeks:=]IIf((days=1,-1:0))
'-- with NO error if no local variable days exists.
'VBA will assume local variable days=0
Dim hours As Integer
shift = timedelta(hours:=hours) '-- perfectly valid (param hours:=local hours)
'-- timedelta(0,hours:=15,3) '-- illegal (it is not clear whether you meant days:=3 or minutes:=3)
'VBA expects a named parameter for 3
End Sub