You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,6 @@ layout: default
5
5
title: Sample Programs in Every Language
6
6
---
7
7
8
-
Welcome to Sample Programs in Every Language, a collection of code snippets in as many languages as possible. Thanks for taking an interest in our collection which currently contains 1495 articles written by 281 authors.
8
+
Welcome to Sample Programs in Every Language, a collection of code snippets in as many languages as possible. Thanks for taking an interest in our collection which currently contains 1496 articles written by 281 authors.
9
9
10
10
If you'd like to contribute to this growing collection, check out our [contributing document](https://github.com/TheRenegadeCoder/sample-programs/blob/master/.github/CONTRIBUTING.md) for more information. In addition, you can explore our documentation which is organized by [project](/projects) and by [language](/languages). If you don't find what you're look for, check out our list of related [open-source projects](/related). Finally, if code isn't your thing but you'd still like to help, there are plenty of other ways to [support the project](https://therenegadecoder.com/updates/5-ways-you-can-support-the-renegade-coder/).
Copy file name to clipboardExpand all lines: docs/languages/index.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ layout: default
6
6
title: Programming Languages
7
7
---
8
8
9
-
Welcome to the Languages page! Here, you'll find a list of all of the languages represented in the collection. At this time, there are 156 languages, of which 155 are tested, 1 is untestable, and 1301 code snippets.
9
+
Welcome to the Languages page! Here, you'll find a list of all of the languages represented in the collection. At this time, there are 156 languages, of which 155 are tested, 1 is untestable, and 1302 code snippets.
10
10
11
11
## Language Breakdown
12
12
@@ -18,7 +18,7 @@ Here are the percentages for each language in the collection:
Welcome to the [Maximum Subarray](https://sampleprograms.io/projects/maximum-subarray) in [Tcl](https://sampleprograms.io/languages/tcl) page! Here, you'll find the source code for this program as well as a description of how the program works.
26
+
27
+
## Current Solution
28
+
29
+
{% raw %}
30
+
31
+
```tcl
32
+
proc usage {} {
33
+
puts stderr {Usage: Please provide a list of integers in the format: "1, 2, 3, 4, 5"}
34
+
exit 1
35
+
}
36
+
37
+
proc parseList {s} {
38
+
set tokens [split [string trim $s] ","]
39
+
if {[llength $tokens] < 1} { usage }
40
+
41
+
set result {}
42
+
43
+
set result {}
44
+
foreach token $tokens {
45
+
set t [string trim $token]
46
+
if {$t eq "" || [catch {expr {int($t)}} val]} usage
47
+
lappend result $val
48
+
}
49
+
return $result
50
+
}
51
+
52
+
proc maximumSubarraySum {numbers} {
53
+
if {[llength $numbers] == 0} { return 0 }
54
+
55
+
set currentSum [lindex $numbers 0]
56
+
set maxSum $currentSum
57
+
58
+
for {set i 1} {$i < [llength $numbers]} {incr i} {
59
+
set val [lindex $numbers $i]
60
+
set currentSum [expr {max($val, $currentSum + $val)}]
61
+
set maxSum [expr {max($maxSum, $currentSum)}]
62
+
}
63
+
64
+
return $maxSum
65
+
}
66
+
67
+
if {$argc != 1} { usage }
68
+
69
+
set numbers [parseList [lindex $argv 0]]
70
+
puts [maximumSubarraySum $numbers]
71
+
72
+
```
73
+
74
+
{% endraw %}
75
+
76
+
Maximum Subarray in [Tcl](https://sampleprograms.io/languages/tcl) was written by:
77
+
78
+
- Ștefan-Iulian Alecu
79
+
80
+
If you see anything you'd like to change or update, [please consider contributing](https://github.com/TheRenegadeCoder/sample-programs).
81
+
82
+
## How to Implement the Solution
83
+
84
+
No 'How to Implement the Solution' section available. [Please consider contributing](https://github.com/TheRenegadeCoder/sample-programs-website).
85
+
86
+
## How to Run the Solution
87
+
88
+
No 'How to Run the Solution' section available. [Please consider contributing](https://github.com/TheRenegadeCoder/sample-programs-website).
0 commit comments