Skip to content

Commit 6ecec04

Browse files
committed
A little Zig
1 parent 6cb085c commit 6ecec04

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

zig/README.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,45 @@
11
<img src="https://raw.githubusercontent.com/rtoal/ple/main/docs/resources/zig-logo-64.png">
22

3-
# Zig
3+
# Zig Explorations
44

5-
## Zig Examples:
5+
To build and run Zig programs on your local machine, download and install Zig from the [Zig Download](https://ziglang.org/download/) or use your favorite package manager, e.g. `brew install zig` on macOS.
66

7-
To get Zig:
8-
<details><summary><b>MacOS</b></summary>
9-
10-
<br />In your terminal (Mac Terminal): <br />
7+
Once installed, programs in this folder can be run from the command line like so:
118

12-
After installing homebrew:
9+
```
10+
zig run triple.zig
11+
```
1312

14-
```sh
15-
$ brew install zig
16-
```
17-
</details>
18-
<details><summary><b>Windows/Linux</b></summary>
19-
20-
Download zig from the website:
21-
- [Zig Download](https://ziglang.org/download/)
13+
```
14+
zig run permutations.zig -- I like carrots
15+
```
2216

23-
</details>
17+
```
18+
zig run top_ten_scorers.zig < ../test/wnba_input
19+
```
2420

25-
## About Zig:
21+
## About Zig
2622

27-
The Zig language was founded by Andrew Kelley in 2016. It was created to replace the <a href="https://github.com/rtoal/ple/tree/main/c">C</a> programming language and be more pragmatic. Zig offers many advancements such as features to improve safety, simple syntax, and a testing framework built into the language. The language also provides strong compile-time guarantees and aims to eliminate common programming errors. While it is a newer language, many developers approve of its capabilities.
23+
The Zig language was created by Andrew Kelley in 2016, as a pragmatic alternative to the venerable <a href="https://github.com/rtoal/ple/tree/main/c">C</a> programming language. Zig offers many safety features and a comprehensive ecosystem for building and testing. It is known for having “no surprises”: there are no hidden function calls and no hidden memory allocations.
2824

29-
## Zig Resources:
25+
## Zig Resources
3026

3127
Continue your exploration of Zig via:
3228

3329
- [Zig Home Page](https://ziglang.org)
34-
- [Zig Docs](https://ziglang.org/documentation/0.10.1/)
30+
- [Zig Docs](https://ziglang.org/documentation/master/)
3531
- [Intro to Zig](https://www.youtube.com/watch?v=YXrb-DqsBNU)
36-
- [ZigLearn](https://ziglearn.org/chapter-1/)
37-
- [Zig Wiki](https://en.wikipedia.org/wiki/Zig_(programming_language))
32+
- [ZigLearn](https://ziglearn.org/learn/)
33+
- [Wikipedia](<https://en.wikipedia.org/wiki/Zig_(programming_language)>)
3834

3935
## Zig Open Source Projects
4036

41-
Studying, and contributing to, open source projects is an excellent way to improve your proficiency in any language. You may enjoy:
37+
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:
4238

43-
- [Zig Open Source](https://github.com/kennethreitz/requests)
39+
- [Trending Lua Repositories on GitHub](https://github.com/trending/zig)
40+
- [tigerbeetle](https://github.com/tigerbeetle/tigerbeetle)
41+
- [asciigen](https://github.com/seatedro/asciigen)
42+
43+
You can contribute to Zig itself:
44+
45+
- [Zig](https://github.com/ziglang/zig)

zig/permuations.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ fn printPermutations(a: []u8, n: usize) void {
99
printPermutations(a, n - 1);
1010
const j = if (n % 2 == 0) 0 else i;
1111

12-
const temp = a[j];
12+
const old_a_j = a[j];
1313
a[j] = a[n];
14-
a[n] = temp;
14+
a[n] = old_a_j;
1515
}
1616
printPermutations(a, n - 1);
1717
}
1818
}
1919

2020
pub fn main() anyerror!void {
21-
var args = try std.process.argsAlloc(std.heap.page_allocator);
21+
const args = try std.process.argsAlloc(std.heap.page_allocator);
2222
defer std.process.argsFree(std.heap.page_allocator, args);
2323

2424
// Skip the first argument which is the program's own path

0 commit comments

Comments
 (0)