September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
1
Task/Integer-sequence/00META.yaml
Normal file
1
Task/Integer-sequence/00META.yaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
--- {}
|
||||
34
Task/Integer-sequence/8080-Assembly/integer-sequence-2.8080
Normal file
34
Task/Integer-sequence/8080-Assembly/integer-sequence-2.8080
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
ORG 0100H
|
||||
BITS EQU 128 ; 128 bits of precision
|
||||
BYTES EQU BITS / 8 ; Number of bytes we store those bits in
|
||||
|
||||
; Zero out the storage for our number
|
||||
LXI H,BUFR ; HL points at BUFR. (HL is idiomatically used for pointers)
|
||||
MVI C,BYTES ; C holds the number of bytes we'll use
|
||||
XRA A ; XOR with A is a 1-byte instruction to set A to zero
|
||||
INIT: MOV M,A ; Store 0 to address pointed to by HL
|
||||
INX H ; Advance HL to the next byte
|
||||
DCR C ; Count down
|
||||
JNZ INIT ; Keep looping if we're not done
|
||||
|
||||
; The "very long integer" is zeroed, so start the loop
|
||||
LOOP: CALL PRBUFR ; Output our number
|
||||
LXI H,BUFR ; HL Points to BUFR
|
||||
MVI C,BYTES ; Count down (assume fewer than 256 bytes in our integer)
|
||||
NEXT: INR M ; Increment the byte pointed to by HL. Sets the zero flag
|
||||
JNZ LOOP ; If the increment didn't overflow A, start the loop over
|
||||
; This byte overflowed, so we need to advance to the next byte in our number
|
||||
INX H ; We store our byes in order of increasing significance
|
||||
DCR C ; Count down to make sure we don't overflow our buffer
|
||||
JNZ NEXT ; jump to process the next, more significant byte
|
||||
|
||||
; If we get here, we have overflowed our integer!
|
||||
HALT ; TODO: probably something other than "halt the CPU"
|
||||
|
||||
PRBUFR: ; TODO, a subroutine that shows all of the digits in BUFR on the console
|
||||
; Assume that this code trashes all our registers...
|
||||
RET
|
||||
|
||||
BUFR: ; This space will hold our number
|
||||
; We zero this memory before the loop
|
||||
END
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
import extensions.
|
||||
import extensions;
|
||||
|
||||
program =
|
||||
[
|
||||
var i := 0u.
|
||||
public program()
|
||||
{
|
||||
var i := 0u;
|
||||
while (true)
|
||||
[
|
||||
console printLine(i).
|
||||
{
|
||||
console.printLine(i);
|
||||
|
||||
i += 1u
|
||||
]
|
||||
].
|
||||
}
|
||||
}
|
||||
|
|
|
|||
35
Task/Integer-sequence/LLVM/integer-sequence.llvm
Normal file
35
Task/Integer-sequence/LLVM/integer-sequence.llvm
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
; This is not strictly LLVM, as it uses the C library function "printf".
|
||||
; LLVM does not provide a way to print values, so the alternative would be
|
||||
; to just load the string into memory, and that would be boring.
|
||||
|
||||
; Additional comments have been inserted, as well as changes made from the output produced by clang such as putting more meaningful labels for the jumps
|
||||
|
||||
;--- The declarations for the external C functions
|
||||
declare i32 @printf(i8*, ...)
|
||||
|
||||
$"FORMAT_STR" = comdat any
|
||||
@"FORMAT_STR" = linkonce_odr unnamed_addr constant [4 x i8] c"%u\0A\00", comdat, align 1
|
||||
|
||||
; Function Attrs: noinline nounwind optnone uwtable
|
||||
define i32 @main() #0 {
|
||||
%1 = alloca i32, align 4 ;-- allocate i
|
||||
store i32 0, i32* %1, align 4 ;-- store i as 0
|
||||
br label %loop
|
||||
|
||||
loop:
|
||||
%2 = load i32, i32* %1, align 4 ;-- load i
|
||||
%3 = add i32 %2, 1 ;-- increment i
|
||||
store i32 %3, i32* %1, align 4 ;-- store i
|
||||
%4 = icmp ne i32 %3, 0 ;-- i != 0
|
||||
br i1 %4, label %loop_body, label %exit
|
||||
|
||||
loop_body:
|
||||
%5 = load i32, i32* %1, align 4 ;-- load i
|
||||
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"FORMAT_STR", i32 0, i32 0), i32 %5)
|
||||
br label %loop
|
||||
|
||||
exit:
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||
3
Task/Integer-sequence/Ol/integer-sequence-1.ol
Normal file
3
Task/Integer-sequence/Ol/integer-sequence-1.ol
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(let loop ((n 1))
|
||||
(print n)
|
||||
(loop (+ 1 n)))
|
||||
4
Task/Integer-sequence/Ol/integer-sequence-2.ol
Normal file
4
Task/Integer-sequence/Ol/integer-sequence-2.ol
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(let loop ((n 2))
|
||||
(print n)
|
||||
(unless (> n 100000000000000000000000000000000)
|
||||
(loop (* n n))))
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
include bigatom.e
|
||||
bigatom b = ba_new(0)
|
||||
while 1 do
|
||||
ba_printf(1,"%B\n",b)
|
||||
b = ba_add(b,1)
|
||||
include mpfr.e
|
||||
mpz b = mpz_init(0)
|
||||
while true do
|
||||
mpz_add_ui(b,b,1)
|
||||
mpfr_printf(1,"%Zd\n",b)
|
||||
end while
|
||||
|
|
|
|||
1
Task/Integer-sequence/Q/integer-sequence-1.q
Normal file
1
Task/Integer-sequence/Q/integer-sequence-1.q
Normal file
|
|
@ -0,0 +1 @@
|
|||
({-1 string x; x+1}\) 1
|
||||
1
Task/Integer-sequence/Q/integer-sequence-2.q
Normal file
1
Task/Integer-sequence/Q/integer-sequence-2.q
Normal file
|
|
@ -0,0 +1 @@
|
|||
i:0; while[1;-1 string (i+:1)]
|
||||
|
|
@ -1 +1 @@
|
|||
0 [ [ putn space ] sip 1+ dup 0 <> ] while drop
|
||||
#0 [ [ n:put spa ] sip n:inc dup n:-zero? ] while drop
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
Imports System.Console
|
||||
|
||||
Module Module1
|
||||
|
||||
Dim base, b1 As Long, digits As Integer, sf As String, st As DateTime,
|
||||
ar As List(Of Long) = {0L}.ToList, c As Integer = ar.Count - 1
|
||||
|
||||
Sub Increment(n As Integer)
|
||||
If ar(n) < b1 Then
|
||||
ar(n) += 1
|
||||
Else
|
||||
ar(n) = 0 : If n > 0 Then
|
||||
Increment(n - 1)
|
||||
Else
|
||||
Try
|
||||
ar.Insert(0, 1L) : c += 1
|
||||
Catch ex As Exception
|
||||
WriteLine("Failure when trying to increase beyond {0} digits", CDbl(c) * digits)
|
||||
TimeStamp("error")
|
||||
Stop
|
||||
End Try
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub TimeStamp(cause As String)
|
||||
With DateTime.Now - st
|
||||
WriteLine("Terminated by {5} at {0} days, {1} hours, {2} minutes, {3}.{4} seconds",
|
||||
.Days, .Hours, .Minutes, .Seconds, .Milliseconds, cause)
|
||||
End With
|
||||
End Sub
|
||||
|
||||
Sub Main(args As String())
|
||||
digits = Long.MaxValue.ToString.Length - 1
|
||||
base = CLng(Math.Pow(10, digits)) : b1 = base - 1
|
||||
base = 10 : b1 = 9
|
||||
sf = "{" & base.ToString.Replace("1", "0:") & "}"
|
||||
st = DateTime.Now
|
||||
While Not KeyAvailable
|
||||
Increment(c) : Write(ar.First)
|
||||
For Each item In ar.Skip(1) : Write(sf, item) : Next : WriteLine()
|
||||
End While
|
||||
TimeStamp("keypress")
|
||||
End Sub
|
||||
End Module
|
||||
Loading…
Add table
Add a link
Reference in a new issue