Skip to content

Commit 76e1892

Browse files
committed
Merge branch 'main' of https://github.com/rtoal/ple
abortsdafsdfsdf the commit.
2 parents 4b0d5bc + dc77656 commit 76e1892

File tree

5 files changed

+50
-24
lines changed

5 files changed

+50
-24
lines changed

cobol/EasyTriples.cob

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
IDENTIFICATION DIVISION.
2+
PROGRAM-ID. Triples.
3+
4+
DATA DIVISION.
5+
WORKING-STORAGE SECTION.
6+
01 A PIC 9(2).
7+
01 B PIC 9(2).
8+
01 C PIC 9(2).
9+
10+
PROCEDURE DIVISION.
11+
PERFORM VARYING C FROM 1 BY 1 UNTIL C > 40
12+
PERFORM VARYING B FROM 1 BY 1 UNTIL B > C
13+
PERFORM VARYING A FROM 1 BY 1 UNTIL A > B
14+
IF A * A + B * B EQUAL TO C * C
15+
DISPLAY A, ', ', B, ', ', C
16+
END-IF
17+
END-PERFORM
18+
END-PERFORM
19+
END-PERFORM.
20+
STOP RUN.

io/triple.io

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
for(c, 1, 40,
22
for(b, 1, c-1,
33
for(a, 1, b-1,
4-
(a**2 + b**2 == c**2) ifTrue(
4+
if(a**2 + b**2 == c**2,
55
list(a, b, c) join(", ") println))))

lua/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Lua Explorations
44

5-
To build and run Lua programs on your local machine, download and install the Lua system from the [Lua downlaods page](https://www.lua.org/download.html) or use your favorite package manager.
5+
To build and run Lua programs on your local machine, download and install the Lua system from the [Lua downloads page](https://www.lua.org/download.html) or use your favorite package manager.
66

77
Once installed, programs in this folder can be run from the command line like so:
88

@@ -37,16 +37,19 @@ Continue your study of Lua via:
3737
- [Awesome Lua](https://github.com/LewisJEllis/awesome-lua)
3838
- [Lua Home](http://www.lua.org/)
3939
- [List of Lua Books](http://www.lua.org/docs.html#books)
40-
- [Lua Reference Manual](http://www.lua.org/manual/5.4/)
41-
- [The book _Programming in Lua_ by Lua’s creator, Roberto Ierusalimschy](http://www.lua.org/pil/)
40+
- [Lua Reference Manual](http://www.lua.org/manual/)
41+
- The book [_Programming in Lua_](http://www.lua.org/pil/) by Lua’s creator, Roberto Ierusalimschy
4242
- [List of Lua Books](https://realtoughcandy.com/best-lua-books/)
4343
- [List of video games scripted in Lua](<https://en.wikipedia.org/wiki/Category:Lua_(programming_language)-scripted_video_games>)
4444

4545
## Lua Open Source Projects
4646

4747
Studying, and contributing to, open source projects is an excellent way to improve your proficiency in any language. Of the many projects using Lua, you may enjoy:
4848

49+
- [Trending Lua Repositories on GitHub](https://github.com/trending/lua)
50+
- [Top 100 Starred Lua Repositories on GitHub](https://github.com/EvanLi/Github-Ranking/blob/master/Top100/Lua.md)
4951
- [Luvit](https://github.com/luvit/luvit)
52+
- [KOReader](https://github.com/koreader/koreader)
5053
- [CorsixTH](https://github.com/CorsixTH/CorsixTH)
5154
- [termtris](https://github.com/tylerneylon/termtris)
5255
- [PacPac](https://github.com/tylerneylon/pacpac)

lua/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ lua anagrams.lua rats | diff ../test/rats_heap_expected - && \
33
lua and_or_demo.lua && \
44
lua basic_latin_wordcount.lua < ../test/wordcount_ascii_input | diff ../test/wordcount_ascii_expected - && \
55
lua binding.lua && \
6+
lua character_counts.lua && \
7+
lua clockhands.lua && \
68
lua coroutine_demo.lua && \
9+
lua coroutine_wrap_demo.lua && \
710
lua delegation_example.lua && \
811
lua errors.lua && \
912
lua exploring_parameters.lua && \

lua/vectors.lua

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
Vector = (function (class, meta, prototype)
1+
Vector = (function (class)
2+
local meta = {
3+
__add = function(self, v)
4+
return class.new(self.i + v.i, self.j + v.j)
5+
end,
6+
__mul = function(self, v)
7+
return self.i * v.i + self.j * v.j
8+
end,
9+
__tostring = function(self)
10+
return string.format("<%g,%g>", self.i, self.j)
11+
end,
12+
__index = {
13+
magnitude = function(self)
14+
return math.sqrt(self.i * self.i + self.j * self.j)
15+
end
16+
},
17+
}
18+
219
class.new = function (i, j)
320
return setmetatable({i = i, j = j}, meta)
421
end
522

6-
prototype.magnitude = function (self)
7-
return math.sqrt(self.i * self.i + self.j * self.j)
8-
end
9-
10-
meta.__index = prototype
11-
12-
meta.__add = function (self, v)
13-
return class.new(self.i + v.i, self.j + v.j)
14-
end
15-
16-
meta.__mul = function (self, v)
17-
return self.i * v.i + self.j * v.j
18-
end
19-
20-
meta.__tostring = function (self)
21-
return string.format('<%g,%g>', self.i, self.j)
22-
end
23-
2423
return class
25-
end)({}, {}, {})
24+
end)({})
2625

2726
u = Vector.new(3, 4)
2827
v = Vector.new(-5, 10)
2928
assert(tostring(u) == "<3,4>")
3029
assert(tostring(v) == "<-5,10>")
30+
assert(u.i == 3)
3131
assert(u.j == 4)
3232
assert(u:magnitude() == 5.0)
3333
assert(tostring(u + v) == "<-2,14>")

0 commit comments

Comments
 (0)