Skip to content

Commit 39f8c1c

Browse files
authored
Use [#]\n instead of [#] for human readable output (#873)
1 parent 46bf5a3 commit 39f8c1c

File tree

16 files changed

+83
-78
lines changed

16 files changed

+83
-78
lines changed

contents/verlet_integration/code/asm-x64/verlet.s

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
zero: .double 0.0
55
two: .double 2.0
66
half: .double 0.5
7-
verlet_fmt: .string "[#] Time for Verlet integration is:\n%lf\n"
8-
stormer_fmt: .string "[#] Time for Stormer Verlet Integration is:\n%lf\n[#] Velocity for Stormer Verlet Integration is:\n%lf\n"
9-
velocity_fmt: .string "[#] Time for Velocity Verlet Integration is:\n%lf\n[#] Velocity for Velocity Verlet Integration is:\n%lf\n"
7+
verlet_fmt: .string "[#]\nTime for Verlet integration is:\n%lf\n"
8+
stormer_fmt: .string "[#]\nTime for Stormer Verlet Integration is:\n%lf\n[#]\nVelocity for Stormer Verlet Integration is:\n%lf\n"
9+
velocity_fmt: .string "[#]\nTime for Velocity Verlet Integration is:\n%lf\n[#]\nVelocity for Velocity Verlet Integration is:\n%lf\n"
1010
pos: .double 5.0
1111
acc: .double -10.0
1212
dt: .double 0.01

contents/verlet_integration/code/c++/verlet.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,19 @@ int main() {
6464
// each of these functions.
6565

6666
double time = verlet(5.0, -10, 0.01);
67-
std::cout << "[#] Time for Verlet integration is:\n" \
67+
std::cout << "[#]\nTime for Verlet integration is:\n" \
6868
<< time << std::endl;
6969

7070
timestep timestep_sv = stormer_verlet(5.0, -10, 0.01);
71-
std::cout << "[#] Time for Stormer Verlet integration is:\n" \
71+
std::cout << "[#]\nTime for Stormer Verlet integration is:\n" \
7272
<< timestep_sv.time << std::endl;
73-
std::cout << "[#] Velocity for Stormer Verlet integration is:\n" \
73+
std::cout << "[#]\nVelocity for Stormer Verlet integration is:\n" \
7474
<< timestep_sv.vel << std::endl;
7575

7676
timestep timestep_vv = velocity_verlet(5.0, -10, 0.01);
77-
std::cout << "[#] Time for velocity Verlet integration is:\n" \
77+
std::cout << "[#]\nTime for velocity Verlet integration is:\n" \
7878
<< timestep_vv.time << std::endl;
79-
std::cout << "[#] Velocity for velocity Verlet integration is:\n" \
79+
std::cout << "[#]\nVelocity for velocity Verlet integration is:\n" \
8080
<< timestep_vv.vel << std::endl;
8181

8282
return 0;

contents/verlet_integration/code/c/verlet.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ int main() {
4646
double time, vel;
4747

4848
verlet(&time, 5.0, -10, 0.01);
49-
printf("[#] Time for Verlet integration is:\n");
49+
printf("[#]\nTime for Verlet integration is:\n");
5050
printf("%lf\n", time);
5151

5252
stormer_verlet(&time, &vel, 5.0, -10, 0.01);
53-
printf("[#] Time for Stormer Verlet integration is:\n");
53+
printf("[#]\nTime for Stormer Verlet integration is:\n");
5454
printf("%lf\n", time);
55-
printf("[#] Velocity for Stormer Verlet integration is:\n");
55+
printf("[#]\nVelocity for Stormer Verlet integration is:\n");
5656
printf("%lf\n", vel);
5757

5858
velocity_verlet(&time, &vel, 5.0, -10, 0.01);
59-
printf("[#] Time for velocity Verlet integration is:\n");
59+
printf("[#]\nTime for velocity Verlet integration is:\n");
6060
printf("%lf\n", time);
61-
printf("[#] Velocity for Stormer Verlet integration is:\n");
61+
printf("[#]\nVelocity for Stormer Verlet integration is:\n");
6262
printf("%lf\n", vel);
6363

6464
return 0;

contents/verlet_integration/code/clisp/verlet.lisp

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@
3434
while (> p 0)
3535
finally (return (list time vel))))
3636

37-
(format T "[#] Time for Verlet integration:~%")
37+
(format T "[#]~%Time for Verlet integration:~%")
3838
(format T "~d~%" (verlet 5 -10 0.01))
3939

4040
(defvar stormer-verlet-result (stormer-verlet 5 -10 0.01))
41-
(format T "[#] Time for Stormer Verlet integration is:~%")
41+
(format T "[#]~%Time for Stormer Verlet integration is:~%")
4242
(format T "~d~%" (first stormer-verlet-result))
43-
(format T "[#] Velocity for Stormer Verlet integration is:~%")
43+
(format T "[#]~%Velocity for Stormer Verlet integration is:~%")
4444
(format T "~d~%" (second stormer-verlet-result))
4545

4646
(defvar velocity-verlet-result (velocity-verlet 5 -10 0.01))
47-
(format T "[#] Time for velocity Verlet integration is:~%")
47+
(format T "[#]~%Time for velocity Verlet integration is:~%")
4848
(format T "~d~%" (first velocity-verlet-result))
49-
(format T "[#] Velocity for velocity Verlet integration is:~%")
49+
(format T "[#]~%Velocity for velocity Verlet integration is:~%")
5050
(format T "~d~%" (second velocity-verlet-result))

contents/verlet_integration/code/fortran/verlet.f90

+10-5
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,19 @@ SUBROUTINE velocity_verlet(pos, acc, dt, time, vel)
9191
! Verlet
9292
CALL verlet(pos, acc, dt, time)
9393

94-
WRITE(*,*) '[#] Time for Verlet integration:'
94+
WRITE(*,*) '[#]'
95+
WRITE(*,*) 'Time for Verlet integration:'
9596
WRITE(*,*) time
9697

9798
! stormer Verlet
9899
pos = 5d0
99100
CALL stormer_verlet(pos, acc, dt, time, vel)
100101

101-
WRITE(*,*) '[#] Time for Stormer Verlet integration:'
102+
WRITE(*,*) '[#]'
103+
WRITE(*,*) 'Time for Stormer Verlet integration:'
102104
WRITE(*,*) time
103-
WRITE(*,*) '[#] Velocity for Stormer Verlet integration:'
105+
WRITE(*,*) '[#]'
106+
WRITE(*,*) 'Velocity for Stormer Verlet integration:'
104107
WRITE(*,*) vel
105108

106109

@@ -109,9 +112,11 @@ SUBROUTINE velocity_verlet(pos, acc, dt, time, vel)
109112
pos = 5d0
110113
CALL velocity_verlet(pos, acc, dt, time, vel)
111114

112-
WRITE(*,*) '[#] Time for velocity Verlet integration:'
115+
WRITE(*,*) '[#]'
116+
WRITE(*,*) 'Time for velocity Verlet integration:'
113117
WRITE(*,*) time
114-
WRITE(*,*) '[#] Velocity for velocity Verlet integration:'
118+
WRITE(*,*) '[#]'
119+
WRITE(*,*) 'Velocity for velocity Verlet integration:'
115120
WRITE(*,*) vel
116121

117122
END PROGRAM verlet_integration

contents/verlet_integration/code/golang/verlet.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ func velocityVerlet(pos, acc, dt float64) (time, vel float64) {
4343

4444
func main() {
4545
time := verlet(5., -10., .01)
46-
fmt.Println("[#] Time for Verlet integration is:")
46+
fmt.Println("[#]\nTime for Verlet integration is:")
4747
fmt.Println(time)
4848

4949
time, vel := stormerVerlet(5., -10., .01)
50-
fmt.Println("[#] Time for Stormer Verlet integration is:")
50+
fmt.Println("[#]\nTime for Stormer Verlet integration is:")
5151
fmt.Println(time)
52-
fmt.Println("[#] Velocity for Stormer Verlet integration is:")
52+
fmt.Println("[#]\nVelocity for Stormer Verlet integration is:")
5353
fmt.Println(vel)
5454

5555
time, vel = velocityVerlet(5., -10., .01)
56-
fmt.Println("[#] Time for velocity Verlet integration is:")
56+
fmt.Println("[#]\nTime for velocity Verlet integration is:")
5757
fmt.Println(time)
58-
fmt.Println("[#] Velocity for velocity Verlet integration is:")
58+
fmt.Println("[#]\nVelocity for velocity Verlet integration is:")
5959
fmt.Println(vel)
6060
}

contents/verlet_integration/code/haskell/verlet.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ main = do
5252
let (_, v, _, t) = last $ takeWhile aboveGround $ trajectory m freefall dt p0
5353
in (show t, show v)
5454

55-
putStrLn "[#] Time for Verlet integration is:"
55+
putStrLn "[#]\nTime for Verlet integration is:"
5656
putStrLn $ fst $ timeVelocity verlet
57-
putStrLn "[#] Time for Stormer Verlet integration is:"
57+
putStrLn "[#]\nTime for Stormer Verlet integration is:"
5858
putStrLn $ fst $ timeVelocity stormerVerlet
59-
putStrLn "[#] Velocity for Stormer Verlet integration is:"
59+
putStrLn "[#]\nVelocity for Stormer Verlet integration is:"
6060
putStrLn $ snd $ timeVelocity stormerVerlet
61-
putStrLn "[#] Time for velocity Verlet integration is:"
61+
putStrLn "[#]\nTime for velocity Verlet integration is:"
6262
putStrLn $ fst $ timeVelocity velocityVerlet
63-
putStrLn "[#] Velocity for velocity Verlet integration is:"
63+
putStrLn "[#]\nVelocity for velocity Verlet integration is:"
6464
putStrLn $ snd $ timeVelocity velocityVerlet

contents/verlet_integration/code/java/Verlet.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,19 @@ static VerletValues velocity_verlet(double pos, double acc, double dt) {
6565
public static void main(String[] args) {
6666

6767
double verletTime = verlet(5.0, -10, 0.01);
68-
System.out.println("[#] Time for Verlet integration is:");
68+
System.out.println("[#]\nTime for Verlet integration is:");
6969
System.out.println(verletTime);
7070

7171
VerletValues stormerVerlet = stormer_verlet(5.0, -10, 0.01);
72-
System.out.println("[#] Time for Stormer Verlet integration is:");
72+
System.out.println("[#]\nTime for Stormer Verlet integration is:");
7373
System.out.println(stormerVerlet.time);
74-
System.out.println("[#] Velocity for Stormer Verlet integration is:");
74+
System.out.println("[#]\nVelocity for Stormer Verlet integration is:");
7575
System.out.println(stormerVerlet.vel);
7676

7777
VerletValues velocityVerlet = velocity_verlet(5.0, -10, 0.01);
78-
System.out.println("[#] Time for velocity Verlet integration is:");
78+
System.out.println("[#]\nTime for velocity Verlet integration is:");
7979
System.out.println(velocityVerlet.time);
80-
System.out.println("[#] Velocity for velocity Verlet integration is:");
80+
System.out.println("[#]\nVelocity for velocity Verlet integration is:");
8181
System.out.println(velocityVerlet.vel);
8282

8383
}

contents/verlet_integration/code/javascript/verlet.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ function velocityVerlet(pos, acc, dt) {
4545
}
4646

4747
const time = verlet(5, -10, 0.01);
48-
console.log(`[#] Time for Verlet integration is:`);
48+
console.log(`[#]\nTime for Verlet integration is:`);
4949
console.log(`${time}`);
5050

5151
const stormer = stormerVerlet(5, -10, 0.01);
52-
console.log(`[#] Time for Stormer Verlet integration is:`);
52+
console.log(`[#]\nTime for Stormer Verlet integration is:`);
5353
console.log(`${stormer.time}`);
54-
console.log(`[#] Velocity for Stormer Verlet integration is:`);
54+
console.log(`[#]\nVelocity for Stormer Verlet integration is:`);
5555
console.log(`${stormer.vel}`);
5656

5757
const velocity = velocityVerlet(5, -10, 0.01);
58-
console.log(`[#] Time for velocity Verlet integration is:`);
58+
console.log(`[#]\nTime for velocity Verlet integration is:`);
5959
console.log(`${velocity.time}`);
60-
console.log(`[#] Velocity for velocity Verlet integration is:`);
60+
console.log(`[#]\nVelocity for velocity Verlet integration is:`);
6161
console.log(`${velocity.vel}`);

contents/verlet_integration/code/julia/verlet.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ end
4646

4747
function main()
4848
time = verlet(5.0, -10.0, 0.01);
49-
println("[#] Time for Verlet integration is:")
49+
println("[#]\nTime for Verlet integration is:")
5050
println("$(time)")
5151

5252
time, vel = stormer_verlet(5.0, -10.0, 0.01);
53-
println("[#] Time for Stormer Verlet integration is:")
53+
println("[#]\nTime for Stormer Verlet integration is:")
5454
println("$(time)")
55-
println("[#] Velocity for Stormer Verlet integration is:")
55+
println("[#]\nVelocity for Stormer Verlet integration is:")
5656
println("$(vel)")
5757

5858
time, vel = velocity_verlet(5.0, -10.0, 0.01);
59-
println("[#] Time for velocity Verlet integration is:")
59+
println("[#]\nTime for velocity Verlet integration is:")
6060
println("$(time)")
61-
println("[#] Velocity for velocity Verlet integration is:")
61+
println("[#]\nVelocity for velocity Verlet integration is:")
6262
println("$(vel)")
6363

6464
end

contents/verlet_integration/code/kotlin/verlet.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ fun velocityVerlet(_pos: Double, acc: Double, dt: Double): VerletValues {
4343

4444
fun main(args: Array<String>) {
4545
val verletTime = verlet(5.0, -10.0, 0.01)
46-
println("[#] Time for Verlet integration is:")
46+
println("[#]\nTime for Verlet integration is:")
4747
println("$verletTime")
4848

4949
val stormerVerlet = stormerVerlet(5.0, -10.0, 0.01)
50-
println("[#] Time for Stormer Verlet integration is:")
50+
println("[#]\nTime for Stormer Verlet integration is:")
5151
println("${stormerVerlet.time}")
52-
println("[#] Velocity for Stormer Verlet integration is:")
52+
println("[#]\nVelocity for Stormer Verlet integration is:")
5353
println("${stormerVerlet.vel}")
5454

5555
val velocityVerlet = velocityVerlet(5.0, -10.0, 0.01)
56-
println("[#] Time for Velocity Verlet integration is:")
56+
println("[#]\nTime for Velocity Verlet integration is:")
5757
println("${velocityVerlet.time}")
58-
println("[#] Velocity for Velocity Verlet integration is:")
58+
println("[#]\nVelocity for Velocity Verlet integration is:")
5959
println("${velocityVerlet.vel}")
6060
}

contents/verlet_integration/code/nim/verlet.nim

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ func velocityVerlet(pos_in, acc, dt: float): (float, float) =
4646

4747
when isMainModule:
4848
let timeV = verlet(5.0, -10.0, 0.01)
49-
echo "[#] Time for Verlet integration is:"
49+
echo "[#]\nTime for Verlet integration is:"
5050
echo timeV
5151

5252
let (timeSV, velSV) = stormerVerlet(5.0, -10.0, 0.01)
53-
echo "[#] Time for Stormer Verlet integration is:"
53+
echo "[#]\nTime for Stormer Verlet integration is:"
5454
echo timeSV
55-
echo "[#] Velocity for Stormer Verlet integration is:"
55+
echo "[#]\nVelocity for Stormer Verlet integration is:"
5656
echo velSV
5757

5858
let (timeVV, velVV) = velocityVerlet(5.0, -10.0, 0.01)
59-
echo "[#] Time for velocity Verlet integration is:"
59+
echo "[#]\nTime for velocity Verlet integration is:"
6060
echo timeVV
61-
echo "[#] Velocity for velocity Verlet integration is:"
61+
echo "[#]\nVelocity for velocity Verlet integration is:"
6262
echo velVV

contents/verlet_integration/code/python/verlet.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ def velocity_verlet(pos, acc, dt):
3535

3636
def main():
3737
time = verlet(5, -10, 0.01)
38-
print("[#] Time for Verlet integration is:")
38+
print("[#]\nTime for Verlet integration is:")
3939
print("{:.10f}".format(time))
4040

4141
time, vel = stormer_verlet(5, -10, 0.01)
42-
print("[#] Time for Stormer Verlet integration is:")
42+
print("[#]\nTime for Stormer Verlet integration is:")
4343
print("{:.10f}".format(time))
44-
print("[#] Velocity for Stormer Verlet integration is:")
44+
print("[#]\nVelocity for Stormer Verlet integration is:")
4545
print("{:.10f}".format(vel))
4646

4747
time, vel = velocity_verlet(5, -10, 0.01)
48-
print("[#] Time for velocity Verlet integration is:")
48+
print("[#]\nTime for velocity Verlet integration is:")
4949
print("{:.10f}".format(time))
50-
print("[#] Velocity for velocity Verlet integration is:")
50+
print("[#]\nVelocity for velocity Verlet integration is:")
5151
print("{:.10f}".format(vel))
5252

5353

contents/verlet_integration/code/ruby/verlet.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ def velocity_verlet(pos, acc, dt)
4545

4646
end
4747

48-
puts "[#] Time for Verlet integration is:"
48+
puts "[#]\nTime for Verlet integration is:"
4949
p verlet(5.0, -10, 0.01)
5050

5151
time, vel = stormer_verlet(5.0, -10, 0.01)
52-
puts "[#] Time for Stormer Verlet integration is:"
52+
puts "[#]\nTime for Stormer Verlet integration is:"
5353
p time
54-
puts "[#] Velocity for Stormer Verlet integration is:"
54+
puts "[#]\nVelocity for Stormer Verlet integration is:"
5555
p vel
5656

5757
time, vel = velocity_verlet(5.0, -10, 0.01)
58-
puts "[#] Time for velocity Verlet integration is:"
58+
puts "[#]\nTime for velocity Verlet integration is:"
5959
p time
60-
puts "[#] Velocity for velocity Verlet integration is:"
60+
puts "[#]\nVelocity for velocity Verlet integration is:"
6161
p vel

contents/verlet_integration/code/rust/verlet.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ fn main() {
4949
let (time_sv, vel_sv) = stormer_verlet(5.0, -10.0, 0.01);
5050
let (time_vv, vel_vv) = velocity_verlet(5.0, -10.0, 0.01);
5151

52-
println!("[#] Time for Verlet integration is:");
52+
println!("[#]\nTime for Verlet integration is:");
5353
println!("{}", time_v);
5454

55-
println!("[#] Time for Stormer Verlet integration is:");
55+
println!("[#]\nTime for Stormer Verlet integration is:");
5656
println!("{}", time_sv);
57-
println!("[#] Velocity for Stormer Verlet integration is:");
57+
println!("[#]\nVelocity for Stormer Verlet integration is:");
5858
println!("{}", vel_sv);
5959

60-
println!("[#] Time for velocity Verlet integration is:");
60+
println!("[#]\nTime for velocity Verlet integration is:");
6161
println!("{}", time_vv);
62-
println!("[#] Velocity for velocity Verlet integration is:");
62+
println!("[#]\nVelocity for velocity Verlet integration is:");
6363
println!("{}", vel_vv);
6464
}

contents/verlet_integration/code/swift/verlet.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ func velocityVerlet(pos: Double, acc: Double, dt: Double) -> (time: Double, vel:
5050

5151
func main() {
5252
let verletTime = verlet(pos: 5.0, acc: -10.0, dt: 0.01)
53-
print("[#] Time for Verlet integration is:")
53+
print("[#]\nTime for Verlet integration is:")
5454
print("\(verletTime)")
5555

5656
let stormer = stormerVerlet(pos: 5.0, acc: -10.0, dt: 0.01);
57-
print("[#] Time for Stormer Verlet integration is:")
57+
print("[#]\nTime for Stormer Verlet integration is:")
5858
print("\(stormer.time)")
59-
print("[#] Velocity for Stormer Verlet integration is:")
59+
print("[#]\nVelocity for Stormer Verlet integration is:")
6060
print("\(stormer.vel)")
6161

6262
let velVerlet = velocityVerlet(pos: 5.0, acc: -10, dt: 0.01)
63-
print("[#] Time for velocity Verlet integration is:")
63+
print("[#]\nTime for velocity Verlet integration is:")
6464
print("\(velVerlet.time)")
65-
print("[#] Velocity for velocity Verlet integration is:")
65+
print("[#]\nVelocity for velocity Verlet integration is:")
6666
print("\(velVerlet.vel)")
6767
}
6868

0 commit comments

Comments
 (0)