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 1485 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 1486 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
+8-8Lines changed: 8 additions & 8 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 1291 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 1292 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 [Duplicate Character Counter](https://sampleprograms.io/projects/duplicate-character-counter) 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 string"
34
+
exit 1
35
+
}
36
+
37
+
proc countDuplicates {str} {
38
+
set counts [dict create]
39
+
set order {}
40
+
41
+
foreach ch [split $str {}] {
42
+
if {[string is alnum -strict $ch]} {
43
+
if {![dict exists $counts $ch]} {
44
+
lappend order $ch
45
+
}
46
+
dict incr counts $ch 1
47
+
}
48
+
}
49
+
50
+
set printed 0
51
+
52
+
foreach ch $order {
53
+
set count [dict get $counts $ch]
54
+
if {$count > 1} {
55
+
puts "$ch: $count"
56
+
incr printed
57
+
}
58
+
}
59
+
60
+
if {$printed == 0} {
61
+
puts "No duplicate characters"
62
+
}
63
+
}
64
+
65
+
if {$argc != 1} { usage }
66
+
67
+
set input [string trim [lindex $argv 0]]
68
+
if {$input eq ""} { usage }
69
+
70
+
countDuplicates $input
71
+
72
+
73
+
```
74
+
75
+
{% endraw %}
76
+
77
+
Duplicate Character Counter in [Tcl](https://sampleprograms.io/languages/tcl) was written by:
78
+
79
+
- Ștefan-Iulian Alecu
80
+
81
+
If you see anything you'd like to change or update, [please consider contributing](https://github.com/TheRenegadeCoder/sample-programs).
82
+
83
+
## How to Implement the Solution
84
+
85
+
No 'How to Implement the Solution' section available. [Please consider contributing](https://github.com/TheRenegadeCoder/sample-programs-website).
86
+
87
+
## How to Run the Solution
88
+
89
+
No 'How to Run the Solution' section available. [Please consider contributing](https://github.com/TheRenegadeCoder/sample-programs-website).
0 commit comments