├── .gitignore ├── LICENSE ├── README.md └── snippets ├── c ├── array │ ├── add │ │ └── add.c │ ├── clear remove │ │ └── clear.c │ ├── count │ │ └── count.c │ ├── cut │ │ └── cut.c │ ├── empty │ │ └── empty.c │ ├── get │ │ └── get.c │ ├── iterate │ │ └── iterate.c │ ├── merge add │ │ └── merge.c │ ├── move │ │ └── move.c │ ├── replace │ │ └── replace.c │ ├── reverse │ │ └── reverse.c │ ├── search │ │ └── search.c │ ├── set │ │ └── set.c │ ├── shuffle │ │ └── shuffle.c │ ├── split │ │ └── split.c │ └── var array │ │ └── var.c ├── const │ └── const.c └── sample c │ └── sample.c ├── cpp ├── array │ ├── add │ │ └── add.cpp │ ├── clear remove │ │ └── clear.cpp │ ├── count │ │ └── count.cpp │ ├── cut │ │ └── cut.cpp │ ├── empty │ │ └── empty.cpp │ ├── get │ │ └── get.cpp │ ├── insert │ │ └── insert.cpp │ ├── iterate │ │ └── iterate.cpp │ ├── join │ │ └── join.cpp │ ├── merge add │ │ └── merge.cpp │ ├── move │ │ └── move.cpp │ ├── replace │ │ └── replace.cpp │ ├── reverse │ │ └── reverse.cpp │ ├── search │ │ └── search.cpp │ ├── set │ │ └── set.cpp │ ├── shuffle │ │ └── shuffle.cpp │ ├── split │ │ └── split.cpp │ └── var array │ │ └── var.cpp ├── const │ └── const.cpp └── sample cpp │ └── sample.cpp ├── cs ├── array │ ├── add │ │ └── Add.cs │ ├── clear remove │ │ └── Clear.cs │ ├── count │ │ └── Count.cs │ ├── cut │ │ └── cut.cs │ ├── empty │ │ └── Empty.cs │ ├── get │ │ └── Get.cs │ ├── iterate │ │ └── Iterate.cs │ ├── join │ │ └── Join.cs │ ├── move │ │ └── move.cs │ ├── replace │ │ └── Replace.cs │ ├── reverse │ │ └── Reverse.cs │ ├── search │ │ └── Search.cs │ ├── set │ │ └── SetTest.cs │ ├── shuffle │ │ └── Shuffle.cs │ ├── sort │ │ └── Sort.cs │ ├── split │ │ └── Split.cs │ ├── unique │ │ └── Unique.cs │ └── var array │ │ └── Var.cs └── sample cs │ └── Sample.cs ├── java ├── array │ ├── add │ │ └── Add.java │ ├── clear remove │ │ └── Clear.java │ ├── count │ │ └── Count.java │ ├── cut │ │ └── Cut.java │ ├── empty │ │ └── Empty.java │ ├── get │ │ └── Get.java │ ├── insert │ │ └── Insert.java │ ├── iterate │ │ └── Iterate.java │ ├── join │ │ └── Join.java │ ├── merge add │ │ └── Merge.java │ ├── move │ │ └── Move.java │ ├── replace │ │ └── Replace.java │ ├── reverse │ │ └── Reverse.java │ ├── search │ │ └── Search.java │ ├── set │ │ └── Set.java │ ├── shuffle │ │ └── Shuffle.java │ ├── sort │ │ └── Sort.java │ ├── split │ │ └── Split.java │ ├── unique │ │ └── Unique.java │ └── var array │ │ └── Var.java ├── sample java │ └── Sample.java └── var │ └── Var.java ├── js ├── array │ ├── add │ │ └── add.js │ ├── clear remove │ │ └── clear.js │ ├── compare │ │ └── compare.js │ ├── copy │ │ └── copy.js │ ├── count │ │ └── count.js │ ├── cut │ │ └── cut.js │ ├── empty │ │ └── empty.js │ ├── get │ │ └── get.js │ ├── insert │ │ └── insert.js │ ├── iterate │ │ └── iterate.js │ ├── join │ │ └── join.js │ ├── merge add │ │ └── merge.js │ ├── move │ │ └── move.js │ ├── remove clear │ │ └── remove.js │ ├── replace │ │ └── replace.js │ ├── reverse │ │ └── reverse.js │ ├── search │ │ └── search.js │ ├── set │ │ └── set.js │ ├── shuffle │ │ └── shuffle.js │ ├── sort │ │ └── sort.js │ ├── split │ │ └── split.js │ ├── unique │ │ └── unique.js │ └── var array │ │ └── var.js ├── const │ └── const.js ├── encode │ └── uri encode │ │ └── uri.js ├── sample js │ └── sample.js └── var │ └── var.js ├── php ├── array │ ├── add │ │ └── add.php │ ├── clear remove │ │ └── clear.php │ ├── count │ │ └── count.php │ ├── cut │ │ └── cut.php │ ├── empty │ │ └── empty.php │ ├── get │ │ └── get.php │ ├── insert │ │ └── insert.php │ ├── iterate │ │ └── iterate.php │ ├── join │ │ └── join.php │ ├── merge add │ │ └── merge.php │ ├── move │ │ └── move.php │ ├── remove │ │ └── remove.php │ ├── replace │ │ └── replace.php │ ├── reverse │ │ └── reverse.php │ ├── search │ │ └── search.php │ ├── set │ │ └── set.php │ ├── shuffle │ │ └── shuffle.php │ ├── sort │ │ └── sort.php │ ├── split │ │ └── split.php │ ├── unique │ │ └── unique.php │ └── var array │ │ └── var.php ├── const │ └── const.php ├── encode │ └── uri encode │ │ └── uri.php ├── sample php │ └── sample.php └── var │ └── var.php ├── py ├── array │ ├── add │ │ └── add.py │ ├── clear remove │ │ └── clear.py │ ├── count │ │ └── count.py │ ├── cut │ │ └── cut.py │ ├── empty │ │ └── empty.py │ ├── get │ │ └── get.py │ ├── insert │ │ └── insert.py │ ├── iterate │ │ └── iterate.py │ ├── join │ │ └── join.py │ ├── merge add │ │ └── merge.py │ ├── move │ │ └── move.py │ ├── remove clear │ │ └── remove.py │ ├── replace │ │ └── replace.py │ ├── reverse │ │ └── reverse.py │ ├── search │ │ └── search.py │ ├── set │ │ └── set.py │ ├── shuffle │ │ └── shuffle.py │ └── var array │ │ └── var.py ├── const │ └── const.py ├── sample py │ └── sample.py └── var │ └── var.py ├── rb ├── array │ ├── add │ │ └── add.rb │ ├── clear remove │ │ └── clear.rb │ ├── count │ │ └── count.rb │ ├── cut │ │ └── cut.rb │ ├── empty │ │ └── empty.rb │ ├── get │ │ └── get.rb │ ├── insert │ │ └── insert.rb │ ├── iterate │ │ └── iterate.rb │ ├── join │ │ └── join.rb │ ├── merge add │ │ └── merge.rb │ ├── move │ │ └── move.rb │ ├── replace │ │ └── replace.rb │ ├── reverse │ │ └── reverse.rb │ ├── search │ │ └── search.rb │ ├── set │ │ └── set.rb │ ├── shuffle │ │ └── shuffle.rb │ ├── split │ │ └── split.rb │ └── var array │ │ └── var.rb ├── const │ └── const.rb └── sample rb │ └── sample.rb └── rs ├── array ├── add │ └── add.rs ├── clear remove │ └── clear.rs ├── count │ └── count.rs ├── cut │ └── cut.rs ├── empty │ └── empty.rs ├── get │ └── get.rs ├── remove clear │ └── remove.rs └── set │ └── set.rs ├── const └── const.rs ├── sample rs └── sample.rs └── var └── var.rs /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.o 3 | *.out -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Quick Snippet Reference 2 | Let's build the quickest snippet reference for every programming language, free to use and modify. 3 | 4 | ## FAQ 5 | 6 | ### How is this different from Rosetta Code? 7 | [Rosetta Code](https://rosettacode.org/wiki/Rosetta_Code) is an excellent learning tool that sparks our curiosity by listing versions of the same programs in a variety of languages, visit now if you haven't. The Quick Snippet Reference shares this intention of letting developers compare the differences between languages, but allows referencing them by their common denominator: the minimal problem-solving operations that we need to code. For example, how can we cut a range of items from an array in [Rust](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/cut/cut.rs), [Python](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/cut/cut.py) and [JavaScript](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/cut/cut.js)? The tree of operations with self-explanatory code samples can be explored in the following sections. 8 | 9 | ## Snippets 10 | 11 | | Language | array/add | array/clear | array/compare | array/copy | array/count | array/cut | array/empty | array/get | array/insert | array/iterate | array/join | array/merge | array/move | array/remove | array/replace | array/reverse | array/search | array/set | array/shuffle | array/sort | array/split | array/unique | array/var | const | encode/uri | sample | var | 12 | | ---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | 13 | | C |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/add/add.c) |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/clear%20remove/clear.c) |? |? |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/count/count.c) |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/cut/cut.c) |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/empty/empty.c) |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/get/get.c) |? |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/iterate/iterate.c) |? |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/merge%20add/merge.c) |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/move/move.c) |? |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/replace/replace.c) |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/reverse/reverse.c) |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/search/search.c) |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/set/set.c) |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/shuffle/shuffle.c) |? |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/split/split.c) |? |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/var%20array/var.c) |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/const/const.c) |? |[c](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/sample%20c/sample.c) |? | 14 | | C++ |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/add/add.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/clear%20remove/clear.cpp) |? |? |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/count/count.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/cut/cut.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/empty/empty.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/get/get.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/insert/insert.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/iterate/iterate.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/join/join.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/merge%20add/merge.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/move/move.cpp) |? |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/replace/replace.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/reverse/reverse.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/search/search.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/set/set.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/shuffle/shuffle.cpp) |? |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/split/split.cpp) |? |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/var%20array/var.cpp) |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/const/const.cpp) |? |[cpp](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/sample%20cpp/sample.cpp) |? | 15 | | C# |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/add/Add.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/clear%20remove/Clear.cs) |? |? |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/count/Count.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/cut/cut.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/empty/Empty.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/get/Get.cs) |? |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/iterate/Iterate.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/join/Join.cs) |? |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/move/move.cs) |? |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/replace/Replace.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/reverse/Reverse.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/search/Search.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/set/SetTest.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/shuffle/Shuffle.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/sort/Sort.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/split/Split.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/unique/Unique.cs) |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/var%20array/Var.cs) |? |? |[cs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/sample%20cs/Sample.cs) |? | 16 | | Java |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/add/Add.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/clear%20remove/Clear.java) |? |? |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/count/Count.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/cut/Cut.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/empty/Empty.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/get/Get.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/insert/Insert.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/iterate/Iterate.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/join/Join.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/merge%20add/Merge.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/move/Move.java) |? |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/replace/Replace.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/reverse/Reverse.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/search/Search.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/set/Set.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/shuffle/Shuffle.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/sort/Sort.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/split/Split.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/unique/Unique.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/var%20array/Var.java) |? |? |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/sample%20java/Sample.java) |[java](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/var/Var.java) | 17 | | JavaScript |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/add/add.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/clear%20remove/clear.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/compare/compare.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/copy/copy.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/count/count.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/cut/cut.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/empty/empty.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/get/get.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/insert/insert.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/iterate/iterate.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/join/join.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/merge%20add/merge.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/move/move.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/remove%20clear/remove.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/replace/replace.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/reverse/reverse.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/search/search.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/set/set.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/shuffle/shuffle.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/sort/sort.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/split/split.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/unique/unique.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/var%20array/var.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/const/const.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/encode/uri%20encode/uri.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/sample%20js/sample.js) |[js](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/var/var.js) | 18 | | PHP |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/add/add.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/clear%20remove/clear.php) |? |? |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/count/count.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/cut/cut.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/empty/empty.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/get/get.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/insert/insert.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/iterate/iterate.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/join/join.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/merge%20add/merge.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/move/move.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/remove/remove.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/replace/replace.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/reverse/reverse.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/search/search.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/set/set.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/shuffle/shuffle.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/sort/sort.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/split/split.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/unique/unique.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/var%20array/var.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/const/const.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/encode/uri%20encode/uri.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/sample%20php/sample.php) |[php](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/var/var.php) | 19 | | Python |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/add/add.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/clear%20remove/clear.py) |? |? |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/count/count.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/cut/cut.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/empty/empty.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/get/get.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/insert/insert.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/iterate/iterate.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/join/join.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/merge%20add/merge.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/move/move.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/remove%20clear/remove.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/replace/replace.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/reverse/reverse.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/search/search.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/set/set.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/shuffle/shuffle.py) |? |? |? |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/var%20array/var.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/const/const.py) |? |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/sample%20py/sample.py) |[py](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/var/var.py) | 20 | | Ruby |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/add/add.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/clear%20remove/clear.rb) |? |? |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/count/count.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/cut/cut.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/empty/empty.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/get/get.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/insert/insert.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/iterate/iterate.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/join/join.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/merge%20add/merge.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/move/move.rb) |? |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/replace/replace.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/reverse/reverse.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/search/search.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/set/set.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/shuffle/shuffle.rb) |? |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/split/split.rb) |? |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/var%20array/var.rb) |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/const/const.rb) |? |[rb](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/sample%20rb/sample.rb) |? | 21 | | Rust |[rs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/add/add.rs) |[rs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/clear%20remove/clear.rs) |? |? |[rs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/count/count.rs) |[rs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/cut/cut.rs) |[rs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/empty/empty.rs) |[rs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/get/get.rs) |? |? |? |? |? |[rs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/remove%20clear/remove.rs) |? |? |? |[rs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/set/set.rs) |? |? |? |? |? |[rs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/const/const.rs) |? |[rs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/sample%20rs/sample.rs) |[rs](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/var/var.rs) | 22 | 23 | __Stats__ | 9 languages | 27 operations | 183 snippets | completed 75.3% of 243 | 60 to do 24 | 25 | ### C# 26 |
27 | 28 | * array 29 | * [empty](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/empty/Empty.cs) 30 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/var%20array/Var.cs) 31 | * [shuffle](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/shuffle/Shuffle.cs) 32 | * [sort](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/sort/Sort.cs) 33 | * [iterate](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/iterate/Iterate.cs) 34 | * [get](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/get/Get.cs) 35 | * [set](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/set/SetTest.cs) 36 | * [count](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/count/Count.cs) 37 | * [search](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/search/Search.cs) 38 | * [replace](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/replace/Replace.cs) 39 | * [reverse](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/reverse/Reverse.cs) 40 | * [join](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/join/Join.cs) 41 | * [unique](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/unique/Unique.cs) 42 | * [split](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/split/Split.cs) 43 | * [move](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/move/move.cs) 44 | * [add](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/add/Add.cs) 45 | * [clear](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/clear%20remove/Clear.cs) 46 | * [cut](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/array/cut/cut.cs) 47 | * [sample](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cs/sample%20cs/Sample.cs) 48 |
49 | 50 | 51 | ### C 52 |
53 | 54 | * array 55 | * [empty](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/empty/empty.c) 56 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/var%20array/var.c) 57 | * [shuffle](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/shuffle/shuffle.c) 58 | * [merge](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/merge%20add/merge.c) 59 | * [iterate](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/iterate/iterate.c) 60 | * [get](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/get/get.c) 61 | * [set](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/set/set.c) 62 | * [count](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/count/count.c) 63 | * [search](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/search/search.c) 64 | * [replace](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/replace/replace.c) 65 | * [reverse](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/reverse/reverse.c) 66 | * [split](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/split/split.c) 67 | * [move](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/move/move.c) 68 | * [add](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/add/add.c) 69 | * [clear](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/clear%20remove/clear.c) 70 | * [cut](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/array/cut/cut.c) 71 | * [sample](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/sample%20c/sample.c) 72 | * [const](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/c/const/const.c) 73 |
74 | 75 | 76 | ### Java 77 |
78 | 79 | * array 80 | * [empty](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/empty/Empty.java) 81 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/var%20array/Var.java) 82 | * [shuffle](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/shuffle/Shuffle.java) 83 | * [sort](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/sort/Sort.java) 84 | * [merge](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/merge%20add/Merge.java) 85 | * [iterate](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/iterate/Iterate.java) 86 | * [get](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/get/Get.java) 87 | * [set](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/set/Set.java) 88 | * [count](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/count/Count.java) 89 | * [search](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/search/Search.java) 90 | * [replace](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/replace/Replace.java) 91 | * [reverse](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/reverse/Reverse.java) 92 | * [join](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/join/Join.java) 93 | * [unique](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/unique/Unique.java) 94 | * [split](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/split/Split.java) 95 | * [move](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/move/Move.java) 96 | * [insert](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/insert/Insert.java) 97 | * [add](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/add/Add.java) 98 | * [clear](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/clear%20remove/Clear.java) 99 | * [cut](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/array/cut/Cut.java) 100 | * [sample](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/sample%20java/Sample.java) 101 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/java/var/Var.java) 102 |
103 | 104 | 105 | ### PHP 106 |
107 | 108 | * array 109 | * [empty](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/empty/empty.php) 110 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/var%20array/var.php) 111 | * [shuffle](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/shuffle/shuffle.php) 112 | * [sort](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/sort/sort.php) 113 | * [merge](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/merge%20add/merge.php) 114 | * [remove](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/remove/remove.php) 115 | * [iterate](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/iterate/iterate.php) 116 | * [get](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/get/get.php) 117 | * [set](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/set/set.php) 118 | * [count](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/count/count.php) 119 | * [search](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/search/search.php) 120 | * [replace](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/replace/replace.php) 121 | * [reverse](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/reverse/reverse.php) 122 | * [join](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/join/join.php) 123 | * [unique](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/unique/unique.php) 124 | * [split](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/split/split.php) 125 | * [move](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/move/move.php) 126 | * [insert](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/insert/insert.php) 127 | * [add](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/add/add.php) 128 | * [clear](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/clear%20remove/clear.php) 129 | * [cut](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/array/cut/cut.php) 130 | * [sample](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/sample%20php/sample.php) 131 | * encode 132 | * [uri](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/encode/uri%20encode/uri.php) 133 | * [const](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/const/const.php) 134 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/php/var/var.php) 135 |
136 | 137 | 138 | ### Python 139 |
140 | 141 | * array 142 | * [empty](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/empty/empty.py) 143 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/var%20array/var.py) 144 | * [shuffle](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/shuffle/shuffle.py) 145 | * [merge](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/merge%20add/merge.py) 146 | * [remove](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/remove%20clear/remove.py) 147 | * [iterate](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/iterate/iterate.py) 148 | * [get](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/get/get.py) 149 | * [set](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/set/set.py) 150 | * [count](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/count/count.py) 151 | * [search](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/search/search.py) 152 | * [replace](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/replace/replace.py) 153 | * [reverse](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/reverse/reverse.py) 154 | * [join](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/join/join.py) 155 | * [move](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/move/move.py) 156 | * [insert](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/insert/insert.py) 157 | * [add](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/add/add.py) 158 | * [clear](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/clear%20remove/clear.py) 159 | * [cut](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/array/cut/cut.py) 160 | * [sample](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/sample%20py/sample.py) 161 | * [const](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/const/const.py) 162 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/py/var/var.py) 163 |
164 | 165 | 166 | ### Rust 167 |
168 | 169 | * array 170 | * [empty](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/empty/empty.rs) 171 | * [remove](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/remove%20clear/remove.rs) 172 | * [get](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/get/get.rs) 173 | * [set](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/set/set.rs) 174 | * [count](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/count/count.rs) 175 | * [add](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/add/add.rs) 176 | * [clear](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/clear%20remove/clear.rs) 177 | * [cut](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/array/cut/cut.rs) 178 | * [const](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/const/const.rs) 179 | * [sample](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/sample%20rs/sample.rs) 180 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rs/var/var.rs) 181 |
182 | 183 | 184 | ### C++ 185 |
186 | 187 | * array 188 | * [empty](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/empty/empty.cpp) 189 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/var%20array/var.cpp) 190 | * [shuffle](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/shuffle/shuffle.cpp) 191 | * [merge](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/merge%20add/merge.cpp) 192 | * [iterate](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/iterate/iterate.cpp) 193 | * [get](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/get/get.cpp) 194 | * [set](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/set/set.cpp) 195 | * [count](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/count/count.cpp) 196 | * [search](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/search/search.cpp) 197 | * [replace](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/replace/replace.cpp) 198 | * [reverse](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/reverse/reverse.cpp) 199 | * [join](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/join/join.cpp) 200 | * [split](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/split/split.cpp) 201 | * [move](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/move/move.cpp) 202 | * [insert](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/insert/insert.cpp) 203 | * [add](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/add/add.cpp) 204 | * [clear](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/clear%20remove/clear.cpp) 205 | * [cut](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/array/cut/cut.cpp) 206 | * [sample](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/sample%20cpp/sample.cpp) 207 | * [const](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/cpp/const/const.cpp) 208 |
209 | 210 | 211 | ### JavaScript 212 |
213 | 214 | * array 215 | * [empty](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/empty/empty.js) 216 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/var%20array/var.js) 217 | * [shuffle](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/shuffle/shuffle.js) 218 | * [sort](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/sort/sort.js) 219 | * [merge](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/merge%20add/merge.js) 220 | * [remove](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/remove%20clear/remove.js) 221 | * [iterate](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/iterate/iterate.js) 222 | * [copy](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/copy/copy.js) 223 | * [get](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/get/get.js) 224 | * [set](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/set/set.js) 225 | * [count](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/count/count.js) 226 | * [search](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/search/search.js) 227 | * [replace](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/replace/replace.js) 228 | * [reverse](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/reverse/reverse.js) 229 | * [join](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/join/join.js) 230 | * [compare](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/compare/compare.js) 231 | * [unique](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/unique/unique.js) 232 | * [split](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/split/split.js) 233 | * [move](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/move/move.js) 234 | * [insert](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/insert/insert.js) 235 | * [add](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/add/add.js) 236 | * [clear](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/clear%20remove/clear.js) 237 | * [cut](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/array/cut/cut.js) 238 | * encode 239 | * [uri](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/encode/uri%20encode/uri.js) 240 | * [const](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/const/const.js) 241 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/var/var.js) 242 | * [sample](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/js/sample%20js/sample.js) 243 |
244 | 245 | 246 | ### Ruby 247 |
248 | 249 | * array 250 | * [empty](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/empty/empty.rb) 251 | * [var](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/var%20array/var.rb) 252 | * [shuffle](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/shuffle/shuffle.rb) 253 | * [merge](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/merge%20add/merge.rb) 254 | * [iterate](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/iterate/iterate.rb) 255 | * [get](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/get/get.rb) 256 | * [set](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/set/set.rb) 257 | * [count](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/count/count.rb) 258 | * [search](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/search/search.rb) 259 | * [replace](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/replace/replace.rb) 260 | * [reverse](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/reverse/reverse.rb) 261 | * [join](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/join/join.rb) 262 | * [split](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/split/split.rb) 263 | * [move](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/move/move.rb) 264 | * [insert](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/insert/insert.rb) 265 | * [add](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/add/add.rb) 266 | * [clear](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/clear%20remove/clear.rb) 267 | * [cut](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/array/cut/cut.rb) 268 | * [const](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/const/const.rb) 269 | * [sample](https://github.com/snippetfinder/The-Quick-Snippet-Reference/tree/main/snippets/rb/sample%20rb/sample.rb) 270 |
271 | -------------------------------------------------------------------------------- /snippets/c/array/add/add.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | void print(int array[],int n) { 5 | for(int i=0; i < n; i++){ 6 | printf("%d", array[i]); 7 | } 8 | printf("\n"); 9 | 10 | } 11 | 12 | int main() { 13 | int arraySize = 10; 14 | int array[arraySize]; 15 | array[0] = 3; 16 | array[1] = 2; 17 | int item = 1; 18 | int size = sizeof array / sizeof array[0]; 19 | printf("before adding : \n"); 20 | print(array, arraySize); 21 | array[size] = item; 22 | printf( "after adding element : "); 23 | print(array, arraySize); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /snippets/c/array/clear remove/clear.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | int array[] = {1,2,3,4,5}; 6 | memset(array, 0, sizeof(array)); 7 | for(int i=0;i<5;i++){ 8 | printf("%d \n", array[i]); 9 | } 10 | return 0; 11 | } -------------------------------------------------------------------------------- /snippets/c/array/count/count.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int array[] = {1,2,3,4,5}; 8 | int arraySize = sizeof(array)/ sizeof(array[0]); 9 | printf("%d", arraySize); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /snippets/c/array/cut/cut.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int sourceArray[] = { 5, 4, 3, 2, 1}; 5 | int destinationArray[] = { 85, 40, 13, 2, 91}; 6 | int destinationIndex = 2; 7 | int sourceStart = 1; 8 | int count = 3; 9 | 10 | 11 | int arraySize = sizeof(sourceArray)/sizeof(sourceArray[0]); 12 | 13 | int en = sourceStart + ( arraySize - (sourceStart + count)); 14 | 15 | int remainingArray[en]; 16 | int cutArray[count]; 17 | 18 | int a = 0; 19 | int b = 0; 20 | for(int i=0;i= sourceStart && i < (sourceStart+count)){ 22 | cutArray[a] = sourceArray[i]; 23 | a = a + 1; 24 | }else{ 25 | remainingArray[b] = sourceArray[i]; 26 | b = b + 1; 27 | } 28 | } 29 | 30 | printf("array 1 %d\n"); 31 | for(int i=0;i 2 | #include 3 | 4 | int main() { 5 | int array[] = {1,2,3,4,5}; 6 | memset(array, 0, sizeof(array)); 7 | for(int i=0;i<5;i++){ 8 | printf("%d \n", array[i]); 9 | } 10 | return 0; 11 | } -------------------------------------------------------------------------------- /snippets/c/array/get/get.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int array[] = {1,2,3,4,5}; 5 | int index = 1; 6 | int item = array[index]; 7 | printf("%d \n", item); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /snippets/c/array/iterate/iterate.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int array[] = {1,2,3,4,5}; 5 | for(int i=0;i<5;i++){ 6 | printf("%d \n", array[i]); 7 | } 8 | return 0; 9 | } -------------------------------------------------------------------------------- /snippets/c/array/merge add/merge.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(){ 4 | int m,n,o,i,j,k,temp; 5 | n = 6; 6 | m = 6; 7 | 8 | o=m+n; 9 | 10 | int a[] = {3, 2, 1}; 11 | int b[] = {100, 200, 300}; 12 | int c[20]; 13 | 14 | 15 | //sorting array 1 16 | for(i=0;ia[j+1]){ 19 | temp=a[j]; 20 | a[j]=a[j+1]; 21 | a[j+1]=temp; 22 | } 23 | } 24 | } 25 | 26 | 27 | //sorting array 2 28 | for(i=0;ib[j+1]){ 31 | temp=b[j]; 32 | b[j]=b[j+1]; 33 | b[j+1]=temp; 34 | } 35 | } 36 | } 37 | 38 | printf("Elements of Array1\n"); 39 | for(i=0;i 2 | 3 | int main() { 4 | int sourceArray[] = { 5, 4, 3, 2, 1}; 5 | int destinationArray[] = { 85, 40, 13, 2, 91}; 6 | int destinationIndex = 2; 7 | int sourceStart = 1; 8 | int count = 3; 9 | 10 | 11 | int arraySize = sizeof(sourceArray)/sizeof(sourceArray[0]); 12 | 13 | int en = sourceStart + ( arraySize - (sourceStart + count)); 14 | 15 | int remainingArray[en]; 16 | int cutArray[count]; 17 | 18 | int a = 0; 19 | int b = 0; 20 | for(int i=0;i= sourceStart && i < (sourceStart+count)){ 22 | cutArray[a] = sourceArray[i]; 23 | a = a + 1; 24 | }else{ 25 | remainingArray[b] = sourceArray[i]; 26 | b = b + 1; 27 | } 28 | } 29 | 30 | printf("array 1 %d\n"); 31 | for(int i=0;i 2 | 3 | int main() { 4 | int array[] = {1,2,3,4,5}; 5 | int index = 1; 6 | int item = 100; 7 | array[index] = item; 8 | for(int i=0;i<5;i++){ 9 | printf("%d \n", array[i]); 10 | } 11 | return 0; 12 | } -------------------------------------------------------------------------------- /snippets/c/array/reverse/reverse.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAX_SIZE 100 // Maximum array size 3 | 4 | int main() 5 | { 6 | int arr[MAX_SIZE]; 7 | int size, i, arrIndex, revIndex; 8 | int temp; // Used for swapping 9 | 10 | int array[] = {1,2,3,4,5}; 11 | size = 5; 12 | 13 | 14 | 15 | 16 | revIndex = 0; 17 | arrIndex = size - 1; 18 | while(revIndex < arrIndex) 19 | { 20 | /* Copy value from original array to reverse array */ 21 | temp = arr[revIndex]; 22 | arr[revIndex] = arr[arrIndex]; 23 | arr[arrIndex] = temp; 24 | 25 | revIndex++; 26 | arrIndex--; 27 | } 28 | 29 | /* 30 | * Print reversed array 31 | */ 32 | printf("\nReversed array : "); 33 | for(i=0; i 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int array[] = {1,2,3,4,5}; 8 | int arraySize = sizeof(array)/ sizeof(array[0]); 9 | int item = 4; 10 | int index = -1; 11 | for(int i = 0; i< arraySize; i++){ 12 | if (array[i] == item){ 13 | index = i; 14 | break; 15 | } 16 | } 17 | printf("%d", index); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /snippets/c/array/set/set.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int array[] = {1,2,3,4,5}; 5 | int index = 1; 6 | int item = 100; 7 | array[index] = item; 8 | for(int i=0;i<5;i++){ 9 | printf("%d \n", array[i]); 10 | } 11 | return 0; 12 | } -------------------------------------------------------------------------------- /snippets/c/array/shuffle/shuffle.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void swap (int *a, int *b) 6 | { 7 | int tmp = *a; 8 | *a = *b; 9 | *b = tmp; 10 | } 11 | 12 | void print (int array[], int arraySize) 13 | { 14 | for (int i = 0; i < arraySize; i++) 15 | printf("%d ", array[i]); 16 | printf("\n"); 17 | } 18 | 19 | void shuffle ( int array[], int arraySize ) 20 | { 21 | srand ( time(NULL) ); 22 | for (int i = arraySize-1; i > 0; i--) 23 | { 24 | int j = rand() % (i+1); 25 | swap(&array[i], &array[j]); 26 | } 27 | } 28 | 29 | int main() 30 | { 31 | int array[] = {1,2,3,4,5}; 32 | int arraySize = sizeof(array)/ sizeof(array[0]); 33 | shuffle (array, arraySize); 34 | print(array, arraySize); 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /snippets/c/array/split/split.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | char input_str[] = "5-4-3-2-1"; 7 | char *separator = strtok(input_str, "-"); 8 | while (separator != NULL) 9 | { 10 | printf("%s\n", separator); 11 | separator = strtok(NULL, "-"); 12 | } 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /snippets/c/array/var array/var.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | char msg[15] = "Hello there"; 8 | printf("%s",msg); 9 | int array[] = {1,2,3,4,5}; 10 | int num1 = 10; 11 | printf("%s", num1); 12 | double num2 = 2.3; 13 | printf("%d", num2); 14 | float num3 = 2.34; 15 | printf("%f", num3); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /snippets/c/const/const.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | return 0; 7 | } 8 | 9 | int number1(){ 10 | return 10; 11 | } 12 | 13 | double number2(){ 14 | return 2.3; 15 | } 16 | 17 | float number3(){ 18 | return 2.3; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /snippets/c/sample c/sample.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | printf("Hello, World!"); 4 | return 0; 5 | } -------------------------------------------------------------------------------- /snippets/cpp/array/add/add.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | void print(vector const &a) { 7 | for(int i=0; i < a.size(); i++){ 8 | cout << a.at(i) << ' '; 9 | } 10 | cout << endl; 11 | 12 | } 13 | 14 | int main() { 15 | vector a = {3, 2}; 16 | int item = 1; 17 | cout << "before adding : "; 18 | print(a); 19 | a.push_back(item); 20 | cout << "after adding element : "; 21 | print(a); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /snippets/cpp/array/clear remove/clear.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int array[] = { 1, 2, 3, 4, 5 }; 8 | int arraySize = sizeof(array)/sizeof(array[0]); 9 | fill_n(array, arraySize, 0); 10 | for (int i = 0; i < arraySize; i++) { 11 | cout << array[i] << " "; 12 | } 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /snippets/cpp/array/count/count.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int array[] = {1, 2, 3}; 8 | cout << sizeof(array) / sizeof(array[0]) << endl; // 3 9 | return 0; 10 | } -------------------------------------------------------------------------------- /snippets/cpp/array/cut/cut.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int sourceArray[] = { 5, 4, 3, 2, 1}; 9 | int destinationArray[] = { 85, 40, 13, 2, 91}; 10 | int destinationIndex = 2; 11 | int sourceStart = 1; 12 | int count = 3; 13 | 14 | int arraySize = sizeof(sourceArray)/sizeof(sourceArray[0]); 15 | 16 | int en = sourceStart + ( arraySize - (sourceStart + count)); 17 | 18 | int remainingArray[en]; 19 | int cutArray[count]; 20 | 21 | int a = 0; 22 | int b = 0; 23 | for(int i=0;i= sourceStart && i < (sourceStart+count)){ 25 | cutArray[a] = sourceArray[i]; 26 | a = a + 1; 27 | }else{ 28 | remainingArray[b] = sourceArray[i]; 29 | b = b + 1; 30 | } 31 | } 32 | 33 | cout<<"array 1"< 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int array[] = { 1, 2, 3, 4, 5 }; 8 | int arraySize = sizeof(array)/sizeof(array[0]); 9 | fill_n(array, arraySize, 0); 10 | for (int i = 0; i < arraySize; i++) { 11 | cout << array[i] << " "; 12 | } 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /snippets/cpp/array/get/get.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int array[] = {5, 4, 3, 2, 1}; 8 | int index = 1; 9 | int item = array[index]; 10 | cout << item << endl; // 4 11 | return 0; 12 | } -------------------------------------------------------------------------------- /snippets/cpp/array/insert/insert.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int array[] = {3, 2, 1}; 8 | 9 | cout<<"before inserting"<= 0; i--) { 11 | cout << array[i]; 12 | } 13 | cout << endl; 14 | int item = 100; 15 | int index = 1; 16 | array[index] = item; 17 | 18 | cout<<"after inserting"<= 0; i--) { 20 | cout << array[i]; 21 | } 22 | cout << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /snippets/cpp/array/iterate/iterate.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int array[] = { 1, 2, 3, 4, 5 }; 8 | int arraySize = sizeof(array)/sizeof(array[0]); 9 | for (int i = 0; i < arraySize; i++) { 10 | cout << array[i] << " "; 11 | } 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /snippets/cpp/array/join/join.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int array[] = { 5, 4, 3, 2, 1 }; 9 | 10 | ostringstream stream; 11 | for (int i = 0; i < sizeof(array) / sizeof(array[0]); ++i) { 12 | if (i) stream << "-"; 13 | stream << array[i]; 14 | } 15 | string joined1 = stream.str(); 16 | 17 | cout << joined1 << endl; 18 | } -------------------------------------------------------------------------------- /snippets/cpp/array/merge add/merge.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int array1[] = {3, 2, 1}; 8 | int array2[] = {100, 200, 300}; 9 | 10 | int arraySize1 = sizeof(array1)/sizeof(array1[0]); 11 | int arraySize2 = sizeof(array2)/sizeof(array2[0]); 12 | 13 | int c[arraySize1 + arraySize2]; 14 | 15 | for(int i=0;i 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int sourceArray[] = { 5, 4, 3, 2, 1}; 9 | int destinationArray[] = { 85, 40, 13, 2, 91}; 10 | int destinationIndex = 2; 11 | int sourceStart = 1; 12 | int count = 3; 13 | 14 | 15 | int arraySize = sizeof(sourceArray)/sizeof(sourceArray[0]); 16 | 17 | int en = sourceStart + ( arraySize - (sourceStart + count)); 18 | 19 | int remainingArray[en]; 20 | int cutArray[count]; 21 | 22 | int a = 0; 23 | int b = 0; 24 | for(int i=0;i= sourceStart && i < (sourceStart+count)){ 26 | cutArray[a] = sourceArray[i]; 27 | a = a + 1; 28 | }else{ 29 | remainingArray[b] = sourceArray[i]; 30 | b = b + 1; 31 | } 32 | } 33 | 34 | cout<<"array 1"< 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int array[] = {3, 2, 1}; 8 | 9 | cout<<"before replacing"<= 0; i--) { 11 | cout << array[i]; 12 | } 13 | cout << endl; 14 | int item = 100; 15 | int index = 1; 16 | array[index] = item; 17 | 18 | cout<<"after replacing"<= 0; i--) { 20 | cout << array[i]; 21 | } 22 | cout << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /snippets/cpp/array/reverse/reverse.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | 6 | void reverse(int array[], int arraySize) { 7 | reverse(array, array + arraySize); 8 | } 9 | 10 | int main() 11 | { 12 | int array[] = { 1, 2, 3, 4, 5 }; 13 | int arraySize = sizeof(array)/sizeof(array[0]); 14 | reverse(array, arraySize); 15 | for (int i = 0; i < arraySize; i++) { 16 | cout << array[i] << " "; 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /snippets/cpp/array/search/search.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int find(int array[], int arraySize, int seek) 5 | { 6 | for (int i = 0; i < arraySize; ++i) 7 | { 8 | if (array[i] == seek) return i; 9 | } 10 | return -1; 11 | } 12 | int main() 13 | { 14 | int array[ 5 ] = { 5, 4, 3, 2, 1 }; 15 | int x = find(array,5,4); 16 | cout << x << endl; 17 | } -------------------------------------------------------------------------------- /snippets/cpp/array/set/set.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | int array[] = {3, 2, 1}; 8 | 9 | cout<<"before setting"<= 0; i--) { 11 | cout << array[i]; 12 | } 13 | cout << endl; 14 | int item = 100; 15 | int index = 1; 16 | array[index] = item; 17 | 18 | cout<<"after setting"<= 0; i--) { 20 | cout << array[i]; 21 | } 22 | cout << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /snippets/cpp/array/shuffle/shuffle.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | int main () { 10 | array array {1,2,3,4,5}; 11 | unsigned time_seed = chrono::system_clock::now().time_since_epoch().count(); 12 | 13 | shuffle (array.begin(), array.end(), default_random_engine(time_seed)); 14 | 15 | for (int& el: array){ 16 | cout << ' ' << el; 17 | } 18 | cout << endl; 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /snippets/cpp/array/split/split.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | 5 | void separator_tokenizer(string s) 6 | { 7 | stringstream ss(s); 8 | string word; 9 | while (ss >> word) { 10 | cout << word << endl; 11 | } 12 | } 13 | 14 | int main(int argc, char const* argv[]) 15 | { 16 | string a = "5-4-3-2-1"; 17 | separator_tokenizer(a); 18 | cout << endl; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /snippets/cpp/array/var array/var.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int array[] = { 1, 2, 3, 4, 5 }; 9 | int num1 = 10; 10 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int number() { 7 | return 10; 8 | } 9 | 10 | double decimal() { 11 | return 2.3; 12 | } 13 | 14 | string _string() { 15 | return "Hello there."; 16 | } 17 | 18 | int *array(int arr[]) { 19 | return arr; 20 | } 21 | 22 | string dictionary() { 23 | return "Hello there."; 24 | } 25 | 26 | int main() { 27 | cout << _string(); // Hello there. 28 | return 0; 29 | } -------------------------------------------------------------------------------- /snippets/cpp/sample cpp/sample.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "Hello world!" << endl; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /snippets/cs/array/add/Add.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Add { 4 | static void Main(string[] args) 5 | { 6 | int[] array1 = { 1, 2, 3 }; 7 | int[] array2 = { 4, 5 }; 8 | Array.Resize(ref array1, array1.Length + array2.Length); // ≡ 9 | Array.Copy(array2, 0, array1, array1.Length - array2.Length, array2.Length); // ≡ 10 | 11 | foreach(int el in array1){ 12 | Console.WriteLine(el.ToString()); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /snippets/cs/array/clear remove/Clear.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | public class Clear { 3 | 4 | public static void Main() 5 | { 6 | int[] myArr = {5, 4, 3, 2, 1}; 7 | Console.WriteLine("Before Clearing Array"); 8 | PrintArrayItems(myArr); 9 | Console.WriteLine(); 10 | Array.Clear(myArr, 0, myArr.Length); // ≡ 11 | Console.WriteLine("After Clearing Array"); 12 | PrintArrayItems(myArr); 13 | } 14 | 15 | public static void PrintArrayItems(int[] myArr){ 16 | for (int i = 0; i < myArr.Length; i++) 17 | { 18 | Console.WriteLine("{0}", myArr[i]); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /snippets/cs/array/count/Count.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | public class Count { 4 | static void Main(string[] args) 5 | { 6 | int[] array = { 1, 2, 3 }; 7 | Console.WriteLine("the length of the array is {0}", array.Length); // ≡ 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /snippets/cs/array/cut/cut.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | 4 | public class Replace { 5 | static void Main(string[] args) 6 | { 7 | 8 | Console.WriteLine("array 1"); 9 | int[] sourceArray = { 5, 4, 3, 2, 1}; 10 | int[] destinationArray = { 85, 40, 13, 2, 91}; 11 | int destinationIndex = 2; 12 | int sourceStart = 1; 13 | int count = 3; 14 | 15 | 16 | int arraySize = sourceArray.Length; 17 | 18 | int en = sourceStart + ( arraySize - (sourceStart + count)); 19 | 20 | int[] remainingArray = new int[en]; 21 | int[] cutArray = new int[count]; 22 | 23 | int a = 0; 24 | int b = 0; 25 | for(int i=0;i= sourceStart && i < (sourceStart+count)){ 27 | cutArray[a] = sourceArray[i]; 28 | a = a + 1; 29 | }else{ 30 | remainingArray[b] = sourceArray[i]; 31 | b = b + 1; 32 | } 33 | } 34 | 35 | Console.WriteLine("array 1"); 36 | for(int i=0;i= sourceStart && i < (sourceStart+count)){ 29 | cutArray[a] = sourceArray[i]; 30 | a = a + 1; 31 | }else{ 32 | remainingArray[b] = sourceArray[i]; 33 | b = b + 1; 34 | } 35 | } 36 | 37 | Console.WriteLine("array 1"); 38 | for(int i=0;i randNumber.Next()).ToArray(); // ≡ 11 | foreach (int el in array) 12 | { 13 | Console.WriteLine(el); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /snippets/cs/array/sort/Sort.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | 4 | public class Sort 5 | { 6 | public static void Main() 7 | { 8 | int[] array = { 5, 4, 3, 2, 1 }; 9 | Console.WriteLine("before sorting"); 10 | 11 | foreach(int i in array) { 12 | Console.Write(i + " "); 13 | } 14 | Array.Sort(array); // ≡ 15 | 16 | Console.WriteLine("after sorting"); 17 | 18 | foreach(int el in array){ 19 | Console.WriteLine(el.ToString()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /snippets/cs/array/split/Split.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | 4 | public class Split 5 | { 6 | public static void Main() 7 | { 8 | String phrase = "Coding World:A Computer Science Portal"; 9 | string[] words = phrase.Split(':'); // ≡ 10 | 11 | foreach (var word in words) 12 | { 13 | System.Console.WriteLine(word); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /snippets/cs/array/unique/Unique.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | public class Unique { 4 | 5 | public static void Main() 6 | { 7 | int []array = {1,23,5,2,2,2,4,5}; 8 | 9 | int n = array.Length; 10 | 11 | for (int i = 0; i < n; i++) 12 | { 13 | // is it aready picked? 14 | int j; 15 | for (j = 0; j < i; j++) 16 | if (array[i] == array[j]) 17 | // no need to continue 18 | break; 19 | // If not then print it 20 | if (i == j) 21 | Console.Write(array[i] + " "); 22 | } 23 | 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /snippets/cs/array/var array/Var.cs: -------------------------------------------------------------------------------- 1 | public class var { 2 | static void Main(string[] args) 3 | { 4 | System.Console.WriteLine("Variable"); 5 | } 6 | } -------------------------------------------------------------------------------- /snippets/cs/sample cs/Sample.cs: -------------------------------------------------------------------------------- 1 | // Hello World! program 2 | namespace Sample 3 | { 4 | class Sample { 5 | static void Main(string[] args) 6 | { 7 | System.Console.WriteLine("Hello World!"); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /snippets/java/array/add/Add.java: -------------------------------------------------------------------------------- 1 | package array; 2 | import java.util.Arrays; 3 | 4 | public class Add { 5 | 6 | public static void main(String args[]) { 7 | int[] array = new int[]{3, 2}; 8 | System.out.println(Arrays.toString(array)); 9 | int n = array.length; 10 | int newArray[] = new int[n+1]; // ≡ 11 | int newValue = 7; // ≡ 12 | System.arraycopy(array, 0, newArray, 0, n); // ≡ 13 | newArray[n] = newValue; // ≡ 14 | System.out.println(Arrays.toString(newArray)); 15 | } 16 | } 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /snippets/java/array/clear remove/Clear.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | import java.util.Arrays; 4 | 5 | public class Clear { 6 | 7 | public static void main(String args[]) { 8 | int[] array = new int[]{5, 4, 3, 2, 1}; 9 | System.out.println(Arrays.toString(array)); 10 | // Setting value to empty array 11 | for (int i = 0; i < array.length; i++) { // ≡ 12 | array[i] = 0; // ≡ 13 | } 14 | System.out.println(Arrays.toString(array)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /snippets/java/array/count/Count.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | public class Count { 4 | 5 | public static void main(String args[]) { 6 | int[] array = new int[]{1,2,3}; 7 | int arraySize = array.length; // ≡ 8 | System.out.println("the length of the array is "+arraySize); // prints: the length of the array is 3 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /snippets/java/array/cut/Cut.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | import java.util.Arrays; 4 | 5 | public class Cut { 6 | 7 | public static void main(String args[]) { 8 | int array[] = new int[] { 5, 4, 3, 2, 1}; 9 | int start = 1; 10 | int count = 3; 11 | int[] arrayCut = Arrays.copyOfRange(array,start,start+count); 12 | int[] array2 = Arrays.copyOfRange(array,0,start); 13 | int[] array3 = Arrays.copyOfRange(array,start+count,array.length); 14 | System.out.println(Arrays.toString(arrayCut)); 15 | int array2Len = array2.length; 16 | int array3Len = array3.length; 17 | int[] remining_array = new int[array2Len + array3Len]; 18 | System.arraycopy(array2, 0, remining_array, 0, array2Len); 19 | System.arraycopy(array3, 0, remining_array, array2Len, array3Len); 20 | 21 | System.out.println(Arrays.toString(remining_array)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /snippets/java/array/empty/Empty.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | public class Empty { 4 | 5 | public static void main(String args[]) { 6 | int[] array = new int[]{3, 2}; 7 | if(array.length == 0){ 8 | System.out.println("\n Array is empty "); 9 | }else{ 10 | System.out.println("\n Array has Items "); 11 | } 12 | // clear the array by reassigning to empty array 13 | array = new int[0]; 14 | if(array.length == 0){ 15 | System.out.println("\n Array is empty again "); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /snippets/java/array/get/Get.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | public class Get { 4 | 5 | public static void main(String args[]) { 6 | int[] array = new int[]{5, 4, 3, 2, 1}; 7 | int index = 1; 8 | int item = array[index]; // ≡ 9 | System.out.println(item); // prints 4 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /snippets/java/array/insert/Insert.java: -------------------------------------------------------------------------------- 1 | 2 | package array; 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | 7 | public class Insert { 8 | 9 | private static void addElement( 10 | Integer[] arr, int element, 11 | int position) 12 | { 13 | System.out.println(Arrays.toString(arr)); 14 | 15 | List list = new ArrayList<>( 16 | Arrays.asList(arr)); 17 | 18 | list.add(position , element); 19 | arr = list.toArray(arr); 20 | System.out.println(Arrays.toString(arr)); 21 | } 22 | 23 | public static void main(String args[]) { 24 | Integer[] array = { 3, 2, 1 }; 25 | int item = 100; 26 | int index = 1; 27 | addElement(array , item, index); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /snippets/java/array/iterate/Iterate.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | public class Iterate { 4 | 5 | public static void main(String args[]) { 6 | // iterating array, method 1 7 | int ar[] = { 5, 4, 3, 2, 1 }; 8 | for(int i = 0; i item == array[i]). 11 | findFirst().orElse(-1); 12 | System.out.println(index); 13 | } 14 | } -------------------------------------------------------------------------------- /snippets/java/array/set/Set.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | import java.util.Arrays; 4 | 5 | public class Set { 6 | 7 | public static void main(String args[]) { 8 | int[] array = new int[]{5, 4, 3, 2, 1}; 9 | int index = 1; 10 | int item = 100; 11 | array[index] = item; // ≡ 12 | System.out.println(Arrays.toString(array)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /snippets/java/array/shuffle/Shuffle.java: -------------------------------------------------------------------------------- 1 | package array; 2 | import java.util.Arrays; 3 | import java.util.Random; 4 | 5 | public class Shuffle { 6 | 7 | public static void main(String args[]) { 8 | int[] arr = { 1, 2, 3, 4, 5 }; 9 | Random randNumber = new Random(); 10 | for (int i = 0; i < arr.length; i++) { 11 | int noToSwap = randNumber.nextInt(arr.length); 12 | int temp = arr[noToSwap]; 13 | arr[noToSwap] = arr[i]; 14 | arr[i] = temp; 15 | } 16 | System.out.println(Arrays.toString(arr)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /snippets/java/array/sort/Sort.java: -------------------------------------------------------------------------------- 1 | package array; 2 | import java.util.Arrays; 3 | 4 | public class Sort { 5 | 6 | public static void main(String args[]) { 7 | int [] array = {5, 4, 3, 2, 1}; 8 | Arrays.sort(array); // ≡ 9 | for (int i = 0; i < array.length; i++) { 10 | System.out.println(array[i]); 11 | } 12 | // array (0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5, ) 13 | } 14 | } -------------------------------------------------------------------------------- /snippets/java/array/split/Split.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | public class Split { 4 | 5 | public static void main(String args[]){ 6 | String str = "Coding World:A Computer Science Portal"; 7 | String[] array = str.split(":"); // ≡ 8 | 9 | for (String s : array) 10 | System.out.println(s); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /snippets/java/array/unique/Unique.java: -------------------------------------------------------------------------------- 1 | 2 | package array; 3 | import java.util.Set; 4 | import java.util.List; 5 | import java.util.Arrays; 6 | import java.util.HashSet; 7 | import java.util.TreeSet; 8 | 9 | class Unique { 10 | public static void main(String[] args){ 11 | // method 1 with has set 12 | List aList = Arrays.asList(1,23,5,2,2,2,4,5); 13 | Set hashSet = new HashSet<>(aList); 14 | for (int h : hashSet) 15 | System.out.println(h); 16 | 17 | // method 2 with tree set 18 | Set treeSet = new TreeSet<>(aList); 19 | System.out.println("Created TreeSet is"); 20 | for (int t : treeSet) 21 | System.out.println(t); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /snippets/java/array/var array/Var.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | import java.util.Arrays; 4 | 5 | public class Var { 6 | 7 | public static void main(String args[]) { 8 | // declarations of arrays 9 | int[] array = new int[0]; 10 | System.out.println(Arrays.toString(array)); 11 | int[] IntArr = { 1, 2, 3, 4, 5 }; // ≡ 12 | System.out.println(Arrays.toString(IntArr)); 13 | String [] StringArray = { "evans", "tom" }; 14 | System.out.println(Arrays.toString(StringArray)); 15 | int[][] multidimensionalArrayInt = new int[4][2]; 16 | System.out.println(Arrays.toString(multidimensionalArrayInt)); 17 | String [][] multidimensionalArrayString = new String[4][2]; 18 | System.out.println(Arrays.toString(multidimensionalArrayString)); 19 | 20 | // with inititialization 21 | String[][] salutation = { {"Mr. ", "Mrs. ", "Ms. "}, {"Evans"} }; 22 | System.out.println(Arrays.toString(salutation)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /snippets/java/sample java/Sample.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | public class Sample { 4 | public static void main(String args[]) { 5 | System.out.println("Hello, World!"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /snippets/java/var/Var.java: -------------------------------------------------------------------------------- 1 | package var; 2 | 3 | import java.util.Dictionary; 4 | import java.util.Enumeration; 5 | import java.util.Hashtable; 6 | 7 | public class Var { 8 | 9 | public static void main(String args[]) { 10 | // declarations of arrays 11 | int number = 10; 12 | double decimal = 2.3; 13 | String string = "Hello there."; // ≡ 14 | System.out.println(string); // Hello there. 15 | string = "Goodbye!"; 16 | System.out.println(string); // Goodbye 17 | 18 | Dictionary dict = new Hashtable(); 19 | dict.put("number", 2.3); 20 | dict.put("heigh", 50.3); 21 | 22 | 23 | Enumeration enu = dict.elements(); 24 | 25 | System.out.println("The enumeration of values are:"); 26 | 27 | // values 28 | while (enu.hasMoreElements()) { 29 | System.out.println(enu.nextElement()); 30 | } 31 | 32 | } 33 | } -------------------------------------------------------------------------------- /snippets/js/array/add/add.js: -------------------------------------------------------------------------------- 1 | var array = [3, 2]; 2 | var item = 1; 3 | console.log(array); // [ 3, 2 ] 4 | array.push(item); // ≡ 5 | console.log(array); // [ 3, 2, 1 ] -------------------------------------------------------------------------------- /snippets/js/array/clear remove/clear.js: -------------------------------------------------------------------------------- 1 | var array = [1, 2, 3]; 2 | console.log(array); // [ 1, 2, 3 ] 3 | array.splice(0); // ≡ 4 | console.log(array); // [] -------------------------------------------------------------------------------- /snippets/js/array/compare/compare.js: -------------------------------------------------------------------------------- 1 | // shallow compare: 2 | console.log('shallow:'); 3 | var item1 = 10; 4 | var item2 = 5; 5 | if (item1 !== item2) console.log('items are different'); // ≡ 6 | item2 = 10; 7 | if (item1 === item2) console.log('items are equal'); // ≡ 8 | 9 | // deep compare #1 (non-trivial problem: will require special cases to handle certain objects): 10 | console.log('deep #1:'); 11 | item1 = [1, 2, ['a', 'b', {'c': 2.3, 'd': 3.14}]]; 12 | item2 = [1, 2, ['a', 'b', {'c': 2.3}]]; 13 | if (JSON.stringify(item1) !== JSON.stringify(item2)) console.log('items are different'); // ≡ 14 | item2[2][2]['d'] = 3.14; 15 | if (JSON.stringify(item1) === JSON.stringify(item2)) console.log('items are equal'); // ≡ 16 | 17 | // deep compare #2 (non-trivial problem: will require special cases to handle certain objects): 18 | console.log('deep #2:'); 19 | item2 = [1, 2, ['a', 'b', {'c': 2.3}]]; 20 | if (!deepCompare(item1, item2)) console.log('items are different'); // ≡ 21 | item2[2][2]['d'] = 3.14; 22 | if (deepCompare(item1, item2)) console.log('items are equal'); // ≡ 23 | 24 | // snippet by: crazyx, 2009, https://stackoverflow.com/users/140277/crazyx 25 | // https://stackoverflow.com/questions/1068834/object-comparison-in-javascript 26 | // https://creativecommons.org/licenses/by-sa/3.0/ 27 | function deepCompare () { // ≡ 28 | var i, l, leftChain, rightChain; 29 | 30 | function compare2Objects (x, y) { 31 | var p; 32 | 33 | // remember that NaN === NaN returns false 34 | // and isNaN(undefined) returns true 35 | if (isNaN(x) && isNaN(y) && typeof x === 'number' && typeof y === 'number') { 36 | return true; 37 | } 38 | 39 | // Compare primitives and functions. 40 | // Check if both arguments link to the same object. 41 | // Especially useful on the step where we compare prototypes 42 | if (x === y) { 43 | return true; 44 | } 45 | 46 | // Works in case when functions are created in constructor. 47 | // Comparing dates is a common scenario. Another built-ins? 48 | // We can even handle functions passed across iframes 49 | if ((typeof x === 'function' && typeof y === 'function') || 50 | (x instanceof Date && y instanceof Date) || 51 | (x instanceof RegExp && y instanceof RegExp) || 52 | (x instanceof String && y instanceof String) || 53 | (x instanceof Number && y instanceof Number)) { 54 | return x.toString() === y.toString(); 55 | } 56 | 57 | // At last checking prototypes as good as we can 58 | if (!(x instanceof Object && y instanceof Object)) { 59 | return false; 60 | } 61 | 62 | if (x.isPrototypeOf(y) || y.isPrototypeOf(x)) { 63 | return false; 64 | } 65 | 66 | if (x.constructor !== y.constructor) { 67 | return false; 68 | } 69 | 70 | if (x.prototype !== y.prototype) { 71 | return false; 72 | } 73 | 74 | // Check for infinitive linking loops 75 | if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1) { 76 | return false; 77 | } 78 | 79 | // Quick checking of one object being a subset of another. 80 | // todo: cache the structure of arguments[0] for performance 81 | for (p in y) { 82 | if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) { 83 | return false; 84 | } 85 | else if (typeof y[p] !== typeof x[p]) { 86 | return false; 87 | } 88 | } 89 | 90 | for (p in x) { 91 | if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) { 92 | return false; 93 | } 94 | else if (typeof y[p] !== typeof x[p]) { 95 | return false; 96 | } 97 | 98 | switch (typeof (x[p])) { 99 | case 'object': 100 | case 'function': 101 | 102 | leftChain.push(x); 103 | rightChain.push(y); 104 | 105 | if (!compare2Objects (x[p], y[p])) { 106 | return false; 107 | } 108 | 109 | leftChain.pop(); 110 | rightChain.pop(); 111 | break; 112 | 113 | default: 114 | if (x[p] !== y[p]) { 115 | return false; 116 | } 117 | break; 118 | } 119 | } 120 | 121 | return true; 122 | } 123 | 124 | if (arguments.length < 1) { 125 | return true; //Die silently? Don't know how to handle such case, please help... 126 | // throw "Need two or more arguments to compare"; 127 | } 128 | 129 | for (i = 1, l = arguments.length; i < l; i++) { 130 | 131 | leftChain = []; //Todo: this can be cached 132 | rightChain = []; 133 | 134 | if (!compare2Objects(arguments[0], arguments[i])) { 135 | return false; 136 | } 137 | } 138 | 139 | return true; 140 | } -------------------------------------------------------------------------------- /snippets/js/array/copy/copy.js: -------------------------------------------------------------------------------- 1 | // benchmark: https://stackoverflow.com/a/61523278 2 | // libraries: https://stackoverflow.com/a/122704 3 | 4 | // shallow copy (array and arrayCopy share references to the same items): 5 | console.log('shallow:'); 6 | var array = [1, 2, ['a', 'b']]; 7 | console.log(array); // [ 1, 2, [ 'a', 'b' ] ] 8 | var arrayCopy = [...array]; // ≡ 9 | console.log(arrayCopy); // [ 1, 2, [ 'a', 'b' ] ] 10 | arrayCopy[2].push('c'); 11 | console.log(array); // [ 1, 2, [ 'a', 'b', 'c' ] ] 12 | console.log(arrayCopy); // [ 1, 2, [ 'a', 'b', 'c' ] ] 13 | 14 | // deep copy (array and arrayCopy have different objects for each item and sub-items; 15 | // non-trivial problem: will require special cases to handle certain objects): 16 | console.log('deep:'); 17 | var array = [1, 2, ['a', 'b']]; 18 | console.log(array); // [ 1, 2, [ 'a', 'b' ] ] 19 | var arrayCopy = deepClone(array); // ≡ 20 | console.log(arrayCopy); // [ 1, 2, [ 'a', 'b' ] ] 21 | arrayCopy[2].push('c'); 22 | console.log(array); // [ 1, 2, [ 'a', 'b' ] ] 23 | console.log(arrayCopy); // [ 1, 2, [ 'a', 'b', 'c' ] ] 24 | 25 | // snippet by: Brett Zamir, 2016, https://stackoverflow.com/users/271577/brett-zamir 26 | // https://stackoverflow.com/questions/597588/how-do-you-clone-an-array-of-objects-in-javascript 27 | // https://creativecommons.org/licenses/by-sa/3.0/ 28 | function deepClone (item) { // ≡ 29 | if (Array.isArray(item)) { 30 | var newArr = []; 31 | for (var i = item.length; i-- > 0;) { 32 | newArr[i] = deepClone(item[i]); 33 | } 34 | return newArr; 35 | } 36 | if (typeof item === 'function' && !(/\(\) \{ \[native/).test(item.toString())) { 37 | var obj; 38 | eval('obj = '+ item.toString()); 39 | for (var k in item) { 40 | obj[k] = deepClone(item[k]); 41 | } 42 | return obj; 43 | } 44 | if (item && typeof item === 'object') { 45 | var obj = {}; 46 | for (var k in item) { 47 | obj[k] = deepClone(item[k]); 48 | } 49 | return obj; 50 | } 51 | return item; 52 | } -------------------------------------------------------------------------------- /snippets/js/array/count/count.js: -------------------------------------------------------------------------------- 1 | var array = [3, 2, 1]; 2 | var arraySize = array.length; // ≡ 3 | console.log(arraySize); // 3 -------------------------------------------------------------------------------- /snippets/js/array/cut/cut.js: -------------------------------------------------------------------------------- 1 | var array = [5, 4, 3, 2, 1]; 2 | var start = 1; // 0: first item, 1: second item... 3 | var count = 3; 4 | console.log(array); // [ 5, 4, 3, 2, 1 ] 5 | var arrayCut = array.splice(start, count); // ≡ 6 | console.log(array); // [ 5, 1 ] 7 | console.log(arrayCut); // [ 4, 3, 2 ] -------------------------------------------------------------------------------- /snippets/js/array/empty/empty.js: -------------------------------------------------------------------------------- 1 | var array = []; 2 | if (!array.length) console.log('array is empty'); // ≡ 3 | array.push(100); // add an item 4 | if (array.length) console.log('array has items'); // ≡ 5 | array.splice(0); // clear the array 6 | if (!array.length) console.log('array is empty again'); -------------------------------------------------------------------------------- /snippets/js/array/get/get.js: -------------------------------------------------------------------------------- 1 | var array = [5, 4, 3, 2, 1]; 2 | var index = 1; // 0: first item, 1: second item... 3 | var item = array[index]; // ≡ 4 | console.log(item); // 4 -------------------------------------------------------------------------------- /snippets/js/array/insert/insert.js: -------------------------------------------------------------------------------- 1 | var array = [3, 2, 1]; 2 | var index = 1; // 0: first item, 1: second item... 3 | var item = 100; 4 | console.log(array); // [ 3, 2, 1 ] 5 | array.splice(index, 0, item); // ≡ 6 | console.log(array); // [ 3, 100, 2, 1 ] -------------------------------------------------------------------------------- /snippets/js/array/iterate/iterate.js: -------------------------------------------------------------------------------- 1 | var array = [5, 4, 3, 2, 1]; 2 | for (var index in array) console.log(index, ':', array[index]); // 0 : 5 1 : 4 ... 4 : 1 ≡ 3 | for (var item of array) console.log(item); // 5 4 ... 1 ≡ -------------------------------------------------------------------------------- /snippets/js/array/join/join.js: -------------------------------------------------------------------------------- 1 | var array = [1, 2.3, 'abc', -5, "123"]; 2 | var separator = '-'; 3 | var string = array.join(separator); // ≡ 4 | console.log(string); // 1-2.3-abc--5-123 -------------------------------------------------------------------------------- /snippets/js/array/merge add/merge.js: -------------------------------------------------------------------------------- 1 | var array1 = [3, 2, 1]; 2 | var array2 = [100, 200, 300]; 3 | 4 | var array = array1.concat(array2); // ≡ 5 | console.log(array); // [ 3, 2, 1, 100, 200, 300 ] 6 | 7 | // expand: 8 | var array = [...array1, ...array2]; // ≡ 9 | console.log(array); // [ 3, 2, 1, 100, 200, 300 ] -------------------------------------------------------------------------------- /snippets/js/array/move/move.js: -------------------------------------------------------------------------------- 1 | var sourceArray = [5, 4, 3, 2, 1]; 2 | var destinationArray = ['a', 'b', 'c']; 3 | var sourceStart = 1; // 0: first item, 1: second item... 4 | var destinationIndex = 2; // 2: third item... 5 | var count = 3; 6 | console.log(sourceArray); // [ 5, 4, 3, 2, 1 ] 7 | console.log(destinationArray); // [ 'a', 'b', 'c' ] 8 | destinationArray.splice(destinationIndex, 0, ...sourceArray.splice(sourceStart, count)); // ≡ 9 | console.log(sourceArray); // [ 5, 1 ] 10 | console.log(destinationArray); // [ 'a', 'b', 4, 3, 2, 'c' ] -------------------------------------------------------------------------------- /snippets/js/array/remove clear/remove.js: -------------------------------------------------------------------------------- 1 | // many items: 2 | var array = [5, 4, 3, 2, 1]; 3 | var start = 1; // 0: first item, 1: second item... 4 | var count = 3; 5 | console.log(array); // [ 5, 4, 3, 2, 1 ] 6 | array.splice(start, count); // ≡ 7 | console.log(array); // [ 5, 1 ] -------------------------------------------------------------------------------- /snippets/js/array/replace/replace.js: -------------------------------------------------------------------------------- 1 | var sourceArray = [3, 2, 1]; 2 | var destinationArray = ['a', 'b', 'c', 'd', 'e']; 3 | var index = 1; // 0: first item, 1: second item... 4 | console.log(destinationArray); // [ 'a', 'b', 'c', 'd', 'e' ] 5 | destinationArray.splice(index, sourceArray.length, ...sourceArray); // ≡ 6 | console.log(destinationArray); // [ 'a', 3, 2, 1, 'e' ] -------------------------------------------------------------------------------- /snippets/js/array/reverse/reverse.js: -------------------------------------------------------------------------------- 1 | var array = [1, 2, 3, 4, 5]; 2 | console.log(array); // [ 1, 2, 3, 4, 5 ] 3 | array.reverse(); // ≡ 4 | console.log(array); // [ 5, 4, 3, 2, 1 ] -------------------------------------------------------------------------------- /snippets/js/array/search/search.js: -------------------------------------------------------------------------------- 1 | var array = [5, 4, 3, 2, 1]; 2 | var item = 4; 3 | var index = array.indexOf(item); // 0: first item, 1: second item... ≡ 4 | console.log(index); // 1 -------------------------------------------------------------------------------- /snippets/js/array/set/set.js: -------------------------------------------------------------------------------- 1 | var array = [3, 2, 1]; 2 | var index = 1; // 0: first item, 1: second item... 3 | var item = 100; 4 | console.log(array); // [ 3, 2, 1 ] 5 | array[index] = item; // ≡ 6 | console.log(array); // [ 3, 100, 1 ] -------------------------------------------------------------------------------- /snippets/js/array/shuffle/shuffle.js: -------------------------------------------------------------------------------- 1 | var array = [1, 2, 3, 4, 5]; 2 | array.sort(() => 0.5 - Math.random()); // ≡ 3 | console.log(array); -------------------------------------------------------------------------------- /snippets/js/array/sort/sort.js: -------------------------------------------------------------------------------- 1 | var array = [5, 2, 3, 4, 1]; 2 | array.sort(); // ≡ 3 | console.log(array); // [ 1, 2, 3, 4, 5 ] -------------------------------------------------------------------------------- /snippets/js/array/split/split.js: -------------------------------------------------------------------------------- 1 | var string = '5-4-3-2-1'; 2 | var separator = '-'; 3 | var array = string.split(separator); // ≡ 4 | console.log(array); // [ '5', '4', '3', '2', '1' ] -------------------------------------------------------------------------------- /snippets/js/array/unique/unique.js: -------------------------------------------------------------------------------- 1 | var array = [2, 3, 4, 3, 2, 5, 1]; 2 | var uniqueItems = [...new Set(array)]; // ≡ 3 | console.log(uniqueItems); // [ 2, 3, 4, 5, 1 ] -------------------------------------------------------------------------------- /snippets/js/array/var array/var.js: -------------------------------------------------------------------------------- 1 | var array = []; 2 | var initializedArray = [10, 2.3, "abc"]; // ≡ 3 | var multidimensionalArray = [['xyz', 99], [42, 3.14]]; -------------------------------------------------------------------------------- /snippets/js/const/const.js: -------------------------------------------------------------------------------- 1 | const number = 10; 2 | const decimal = 2.3; 3 | const string = "Hello there."; // ≡ 4 | const array = [2.3, 'Hello there.', [1, 2], {a: 1, b: 2}]; 5 | const dictionary = {number: 2.3, "list": [1, 2], 'values': {a: 1, b: 2}}; 6 | console.log(string); // Hello there. ≡ 7 | 8 | try 9 | { 10 | string = "Goodbye"; // ≡ 11 | } 12 | catch (error) 13 | { 14 | console.log('can\'t change constant'); // ≡ 15 | } -------------------------------------------------------------------------------- /snippets/js/encode/uri encode/uri.js: -------------------------------------------------------------------------------- 1 | var url = "https://example.com"; 2 | var query = 'text="hello"&page=3'; 3 | var parameter = 'black&white'; 4 | console.log(encodeURI(url + '?' + query)); // https://example.com?text=%22hello%22&page=3 ≡ 5 | console.log(url + '?style=' + encodeURIComponent(parameter)); // https://example.com?style=black%26white ≡ 6 | 7 | // Comparison of encoding methods: ≡ 8 | /* ❯❯❯ GENERATOR:TABLE:JAVASCRIPT:Compare() 9 | function Compare() 10 | { 11 | var t = [['character', 'encodeURI', 'encodeURIComponent', 'escape (DEPRECATED)']]; 12 | var cl = ['*', '-', '.', '_', '~', '!', "'", '(', ')', '+', '/', '@', '#', '$', '&', ',', ':', ';', '=', '?', ' ', '"', '%', '<', '>', '[', '\\', ']', '^', '`', '{', '|', '}']; 13 | for (var c of cl) 14 | t.push([c, encodeURI(c), encodeURIComponent(c), escape(c)]); 15 | return t; 16 | } 17 | GENERATOR ❮❮❮ */ -------------------------------------------------------------------------------- /snippets/js/sample js/sample.js: -------------------------------------------------------------------------------- 1 | var message = "Hello, World!"; 2 | console.log(message); -------------------------------------------------------------------------------- /snippets/js/var/var.js: -------------------------------------------------------------------------------- 1 | var number = 10; 2 | var decimal = 2.3; 3 | var string = "Hello there."; // ≡ 4 | var array = [2.3, 'Hello there.', [1, 2], {a: 1, b: 2}]; 5 | var dictionary = {number: 2.3, "list": [1, 2], 'values': {a: 1, b: 2}}; 6 | console.log(string); // Hello there. ≡ 7 | string = "Goodbye!"; // ≡ 8 | console.log(string); // Goodbye! ≡ -------------------------------------------------------------------------------- /snippets/php/array/add/add.php: -------------------------------------------------------------------------------- 1 | 3, 1 => 2, ) 5 | $arraay[] = $item; // ≡ 6 | var_export($arraay); // array (0 => 3, 1 => 2, 2 => 1, ) 7 | ?> -------------------------------------------------------------------------------- /snippets/php/array/clear remove/clear.php: -------------------------------------------------------------------------------- 1 | 1, 1 => 2, 2 => 3, ) 4 | array_splice($arraay, 0); // ≡ 5 | var_export($arraay); // array () 6 | ?> -------------------------------------------------------------------------------- /snippets/php/array/count/count.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /snippets/php/array/cut/cut.php: -------------------------------------------------------------------------------- 1 | 5, 1 => 4, 2 => 3, 3 => 2, 4 => 1, ) 6 | $$arraayCut = array_splice($arraay, $start, $count); // ≡ 7 | var_export($arraay); // array (0 => 5, 1 => 1, ) 8 | var_export($$arraayCut); // array (0 => 4, 1 => 3, 2 => 2, ) 9 | ?> -------------------------------------------------------------------------------- /snippets/php/array/empty/empty.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /snippets/php/array/get/get.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /snippets/php/array/insert/insert.php: -------------------------------------------------------------------------------- 1 | 3, 1 => 2, 2 => 1, ) 6 | array_splice($arraay, $index, 0, $item); // ≡ 7 | var_export($arraay); // array (0 => 3, 1 => 100, 2 => 2, 3 => 1, ) 8 | ?> -------------------------------------------------------------------------------- /snippets/php/array/iterate/iterate.php: -------------------------------------------------------------------------------- 1 | $item) echo $index, ':', $item, ' '; // 0:5 1:4 2:3 3:2 4:1 ≡ 5 | ?> -------------------------------------------------------------------------------- /snippets/php/array/join/join.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /snippets/php/array/merge add/merge.php: -------------------------------------------------------------------------------- 1 | 3, 1 => 2, 2 => 1, 3 => 100, 4 => 200, 5 => 300, ) 7 | ?> -------------------------------------------------------------------------------- /snippets/php/array/move/move.php: -------------------------------------------------------------------------------- 1 | 5, 1 => 4, 2 => 3, 3 => 2, 4 => 1, ) 8 | var_export($destinationArraay); // array (0 => 'a', 1 => 'b', 2 => 'c', ) 9 | array_splice($destinationArraay, $destinationIndex, 0, array_splice($sourceArraay, $sourceStart, $count)); // ≡ 10 | var_export($sourceArraay); // array (0 => 5, 1 => 1, ) 11 | var_export($destinationArraay); // array (0 => 'a', 1 => 'b', 2 => 4, 3 => 3, 4 => 2, 5 => 'c', ) 12 | ?> -------------------------------------------------------------------------------- /snippets/php/array/remove/remove.php: -------------------------------------------------------------------------------- 1 | 5, 1 => 4, 2 => 3, 3 => 2, 4 => 1, ) 6 | $removedItems = array_splice($arraay, $start, $count); // ≡ 7 | var_export($arraay); // array (0 => 5, 1 => 1, ) 8 | var_export($removedItems); // array (0 => 4, 1 => 3, 2 => 2, ) 9 | ?> -------------------------------------------------------------------------------- /snippets/php/array/replace/replace.php: -------------------------------------------------------------------------------- 1 | 3, 1 => 2, 2 => 1, ) 6 | array_splice($arraay, $index, 1, $item); // ≡ 7 | var_export($arraay); // array (0 => 3, 1 => 100, 2 => 1, ) 8 | ?> -------------------------------------------------------------------------------- /snippets/php/array/reverse/reverse.php: -------------------------------------------------------------------------------- 1 | 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5, ) 4 | $arraay = array_reverse($arraay); // ≡ 5 | var_export($arraay); // array (0 => 5, 1 => 4, 2 => 3, 3 => 2, 4 => 1, ) 6 | ?> -------------------------------------------------------------------------------- /snippets/php/array/search/search.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /snippets/php/array/set/set.php: -------------------------------------------------------------------------------- 1 | 3, 1 => 2, 2 => 1, ) 6 | $arraay[$index] = $item; // ≡ 7 | var_export($arraay); // array (0 => 3, 1 => 100, 2 => 1, ) 8 | ?> -------------------------------------------------------------------------------- /snippets/php/array/shuffle/shuffle.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /snippets/php/array/sort/sort.php: -------------------------------------------------------------------------------- 1 | 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5, ) 5 | ?> -------------------------------------------------------------------------------- /snippets/php/array/split/split.php: -------------------------------------------------------------------------------- 1 | '5', 1 => '4', 2 => '3', 3 => '2', 4 => '1', ) 6 | ?> -------------------------------------------------------------------------------- /snippets/php/array/unique/unique.php: -------------------------------------------------------------------------------- 1 | 2, 1 => 3, 2 => 4, 5 => 5, 6 => 1, ) 5 | ?> -------------------------------------------------------------------------------- /snippets/php/array/var array/var.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /snippets/php/const/const.php: -------------------------------------------------------------------------------- 1 | 1, 'b' => 2]]); 6 | define('dictionary', ["number" => 2.3, "list" => [1, 2], 'values' => ["a" => 1, 'b' => 2]]); 7 | echo striing; // Hello there. ≡ 8 | ?> -------------------------------------------------------------------------------- /snippets/php/encode/uri encode/uri.php: -------------------------------------------------------------------------------- 1 | ","%3E","%3E"],["?","%3F","%3F"],["@","%40","%40"],["[","%5B","%5B"],["\\","%5C","%5C"],["]","%5D","%5D"],["^","%5E","%5E"],["`","%60","%60"],["{","%7B","%7B"],["|","%7C","%7C"],["}","%7D","%7D"]] 9 | GENERATOR ❮❮❮ */ 10 | ?> -------------------------------------------------------------------------------- /snippets/php/sample php/sample.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /snippets/php/var/var.php: -------------------------------------------------------------------------------- 1 | 1, 'b' => 2]]; 6 | $dictionary = ["number" => 2.3, "liist" => [1, 2], 'values' => ["a" => 1, 'b' => 2]]; 7 | echo $string; // Hello there. ≡ 8 | ?> -------------------------------------------------------------------------------- /snippets/py/array/add/add.py: -------------------------------------------------------------------------------- 1 | array = [3, 2] 2 | item = 1 3 | print(array) # [3, 2] 4 | array.append(item) # ≡ 5 | print(array) # [3, 2, 1] 6 | 7 | # merge: 8 | array = [3, 2] 9 | item = 1 10 | print(array) # [3, 2] 11 | array += [item] # ≡ 12 | print(array) # [3, 2, 1] -------------------------------------------------------------------------------- /snippets/py/array/clear remove/clear.py: -------------------------------------------------------------------------------- 1 | array = [1, 2, 3] 2 | print(array) # [1, 2, 3] 3 | del array[:] # ≡ 4 | print(array) # [] -------------------------------------------------------------------------------- /snippets/py/array/count/count.py: -------------------------------------------------------------------------------- 1 | array = [1, 2, 3] 2 | arraySize = len(array) # ≡ 3 | print(arraySize) # 3 -------------------------------------------------------------------------------- /snippets/py/array/cut/cut.py: -------------------------------------------------------------------------------- 1 | array = [5, 4, 3, 2, 1] 2 | start = 1 # 0: first item, 1: second item... 3 | count = 3 4 | print(array) # [ 5, 4, 3, 2, 1 ] 5 | arrayCut = array[start:start + count] # ≡ 6 | del array[start:start + count] # ≡ 7 | print(array) # [ 5, 1 ] 8 | print(arrayCut) # [ 4, 3, 2 ] -------------------------------------------------------------------------------- /snippets/py/array/empty/empty.py: -------------------------------------------------------------------------------- 1 | array = [] 2 | if (not len(array)): print('array is empty') # ≡ 3 | array.append(100) # add an item 4 | if (len(array)): print('array has items') # ≡ 5 | del array[:] # clear the array 6 | if (not len(array)): print('array is empty again') -------------------------------------------------------------------------------- /snippets/py/array/get/get.py: -------------------------------------------------------------------------------- 1 | array = [5, 4, 3, 2, 1] 2 | index = 1 # 0: first item, 1: second item... 3 | item = array[index] # ≡ 4 | print(item) # 4 -------------------------------------------------------------------------------- /snippets/py/array/insert/insert.py: -------------------------------------------------------------------------------- 1 | array = [3, 2, 1] 2 | index = 1 # 0: first item, 1: second item... 3 | item = 100 4 | print(array) # [3, 2, 1] 5 | array = array[0:index] + [item] + array[index:] # ≡ 6 | print(array) # [3, 100, 2, 1] -------------------------------------------------------------------------------- /snippets/py/array/iterate/iterate.py: -------------------------------------------------------------------------------- 1 | array = [5, 4, 3, 2, 1] 2 | for index in range(len(array)): print(index, ':', array[index]) # 0 : 5 1 : 4 ... 4 : 1 ≡ 3 | for item in array: print(item) # 5 4 ... 1 ≡ -------------------------------------------------------------------------------- /snippets/py/array/join/join.py: -------------------------------------------------------------------------------- 1 | separator = '-' 2 | 3 | # items are strings only: 4 | array = ['abc', "xyz", '123'] 5 | string = separator.join(array) # ≡ 6 | print(string) # abc-xyz-123 7 | 8 | # not all items are strings: 9 | array = [1, 2.3, 'abc', -5, "123"] 10 | string = separator.join(str(item) for item in array) # ≡ 11 | print(string) # 1-2.3-abc--5-123 -------------------------------------------------------------------------------- /snippets/py/array/merge add/merge.py: -------------------------------------------------------------------------------- 1 | array1 = [3, 2, 1] 2 | array2 = [100, 200, 300] 3 | array1.extend(array2) # ≡ 4 | print(array1) # [ 3, 2, 1, 100, 200, 300 ] 5 | 6 | # add: 7 | array1 = [3, 2, 1] 8 | array2 = [100, 200, 300] 9 | array = array1 + array2 # ≡ 10 | print(array) # [ 3, 2, 1, 100, 200, 300 ] -------------------------------------------------------------------------------- /snippets/py/array/move/move.py: -------------------------------------------------------------------------------- 1 | sourceArray = [5, 4, 3, 2, 1] 2 | destinationArray = ['a', 'b', 'c'] 3 | sourceStart = 1 # 0: first item, 1: second item... 4 | destinationIndex = 2 # 2: third item... 5 | count = 3 6 | print(sourceArray) # [ 5, 4, 3, 2, 1 ] 7 | print(destinationArray) # [ 'a', 'b', 'c' ] 8 | destinationArray = destinationArray[0:destinationIndex] + sourceArray[sourceStart:(sourceStart + count)] + destinationArray[destinationIndex:] # ≡ 9 | del sourceArray[sourceStart:(sourceStart + count)] # ≡ 10 | print(sourceArray) # [ 5, 1 ] 11 | print(destinationArray) # [ 'a', 'b', 4, 3, 2, 'c' ] -------------------------------------------------------------------------------- /snippets/py/array/remove clear/remove.py: -------------------------------------------------------------------------------- 1 | array = [5, 4, 3, 2, 1] 2 | index = 1 # 0: first item, 1: second item... 3 | print(array) # [5, 4, 3, 2, 1] 4 | del array[index] # ≡ 5 | print(array) # [5, 3, 2, 1] 6 | 7 | # many items: 8 | array = [5, 4, 3, 2, 1] 9 | start = 1 # 0: first item, 1: second item... 10 | count = 3 11 | print(array) # [ 5, 4, 3, 2, 1 ] 12 | del array[start:(start + count)] # ≡ 13 | print(array) # [ 5, 1 ] -------------------------------------------------------------------------------- /snippets/py/array/replace/replace.py: -------------------------------------------------------------------------------- 1 | array = [3, 2, 1] 2 | index = 1 # 0: first item, 1: second item... 3 | item = 100 4 | print(array) # [3, 2, 1] 5 | array[index] = item # ≡ 6 | print(array) # [3, 100, 1] -------------------------------------------------------------------------------- /snippets/py/array/reverse/reverse.py: -------------------------------------------------------------------------------- 1 | array = [1, 2, 3, 4, 5] 2 | print(array) # [ 1, 2, 3, 4, 5 ] 3 | array.reverse() # ≡ 4 | print(array) # [ 5, 4, 3, 2, 1 ] -------------------------------------------------------------------------------- /snippets/py/array/search/search.py: -------------------------------------------------------------------------------- 1 | array = [5, 4, 3, 2, 1] 2 | item = 4 3 | index = array.index(item) # 0: first item, 1: second item... ≡ 4 | print(index) # 1 -------------------------------------------------------------------------------- /snippets/py/array/set/set.py: -------------------------------------------------------------------------------- 1 | array = [3, 2, 1] 2 | index = 1 # 0: first item, 1: second item... 3 | item = 100 4 | print(array) # [3, 2, 1] 5 | array[index] = item # ≡ 6 | print(array) # [3, 100, 1] -------------------------------------------------------------------------------- /snippets/py/array/shuffle/shuffle.py: -------------------------------------------------------------------------------- 1 | import random # ≡ 2 | array = [1, 2, 3, 4, 5] 3 | random.shuffle(array) # ≡ 4 | print(array) -------------------------------------------------------------------------------- /snippets/py/array/var array/var.py: -------------------------------------------------------------------------------- 1 | array = [] 2 | initializedArray = [10, 2.3, "abc"] # ≡ 3 | multidimensionalArray = [['xyz', 99], [42, 3.14]] -------------------------------------------------------------------------------- /snippets/py/const/const.py: -------------------------------------------------------------------------------- 1 | # as function: 2 | def number(): return 10 3 | def decimal(): return 2.3 4 | def string(): return "Hello there." # ≡ 5 | def array(): return [2.3, 'Hello there.', [1, 2], {"a": 1, 'b': 2}] 6 | def dictionary(): return {"number": 2.3, 'list': [1, 2], "values": {'a': 1, "b": 2}} 7 | print(string()) # Hello there. ≡ -------------------------------------------------------------------------------- /snippets/py/sample py/sample.py: -------------------------------------------------------------------------------- 1 | message = "Hello, World!" 2 | print(message) -------------------------------------------------------------------------------- /snippets/py/var/var.py: -------------------------------------------------------------------------------- 1 | number = 10 2 | decimal = 2.3 3 | string = "Hello there." # ≡ 4 | array = [2.3, 'Hello there.', [1, 2], {"a": 1, 'b': 2}] 5 | dictionary = {"number": 2.3, 'list': [1, 2], "values": {'a': 1, "b": 2}} 6 | print(string) # Hello there. ≡ 7 | string = "Goodbye!" # ≡ 8 | print(string) # Goodbye! ≡ -------------------------------------------------------------------------------- /snippets/rb/array/add/add.rb: -------------------------------------------------------------------------------- 1 | array = [3, 2] 2 | item = 1 3 | print(array) # [3, 2] 4 | puts "\n" 5 | array.append(item) 6 | print(array) # [3, 2, 1] 7 | puts "\n" 8 | # merge: 9 | array = [3, 2] 10 | item = 1 11 | print(array) # [3, 2]'' 12 | puts "\n" 13 | array += [item] 14 | print(array) # [] -------------------------------------------------------------------------------- /snippets/rb/array/clear remove/clear.rb: -------------------------------------------------------------------------------- 1 | array = [1, 2, 3] 2 | print(array) # [1, 2, 3] 3 | array.clear() # ≡ 4 | print("\n") 5 | print(array) # [] -------------------------------------------------------------------------------- /snippets/rb/array/count/count.rb: -------------------------------------------------------------------------------- 1 | array = [1, 2, 3] 2 | arraySize = array.length() # ≡ 3 | print(arraySize) # 3 -------------------------------------------------------------------------------- /snippets/rb/array/cut/cut.rb: -------------------------------------------------------------------------------- 1 | array = [5, 4, 3, 2, 1] 2 | start = 1 # 0: first item, 1: second item... 3 | count = 3 4 | print(array) # [ 5, 4, 3, 2, 1 ] 5 | print("\n") 6 | arrayCut = array[start,(start + count - 1)] 7 | array.slice!(start,(start + count - 1)) 8 | print(array) # [ 5, 1 ] 9 | print("\n") 10 | print(arrayCut) # [ 4, 3, 2 ] -------------------------------------------------------------------------------- /snippets/rb/array/empty/empty.rb: -------------------------------------------------------------------------------- 1 | array = [] 2 | if (not array.length()) 3 | print("array is empty") # ≡ 4 | end 5 | 6 | array.append(100) # add an item 7 | if (array.length()) 8 | print("array has items\n") # ≡ 9 | end 10 | 11 | array.clear() 12 | 13 | if (array.length() == 0) 14 | print("array is empty again\n") 15 | end -------------------------------------------------------------------------------- /snippets/rb/array/get/get.rb: -------------------------------------------------------------------------------- 1 | array = [5, 4, 3, 2, 1] 2 | index = 1 # 0: first item, 1: second item... 3 | item = array[index] # ≡ 4 | print(item) # 4 -------------------------------------------------------------------------------- /snippets/rb/array/insert/insert.rb: -------------------------------------------------------------------------------- 1 | array = [3, 2, 1] 2 | index = 1 # 0: first item, 1: second item... 3 | item = 100 4 | print(array) # [3, 2, 1] 5 | print("\n") 6 | array = array[0,index] + [item] + array[index,array.length()] # ≡ 7 | print(array) # [3, 100, 2, 1] -------------------------------------------------------------------------------- /snippets/rb/array/iterate/iterate.rb: -------------------------------------------------------------------------------- 1 | array = [5, 4, 3, 2, 1] 2 | for item in array 3 | print(item) 4 | end # 5 4 ... 1 ≡ -------------------------------------------------------------------------------- /snippets/rb/array/join/join.rb: -------------------------------------------------------------------------------- 1 | separator = '-' 2 | 3 | # items are strings only: 4 | array = ['abc', "xyz", '123'] 5 | string = array.join('-') # ≡ 6 | print(string) # abc-xyz-123 7 | print("\n") 8 | # not all items are strings: 9 | array = [1, 2.3, 'abc', -5, "123"] 10 | string = array.join('-') # ≡ 11 | print(string) # 1-2.3-abc--5-123 -------------------------------------------------------------------------------- /snippets/rb/array/merge add/merge.rb: -------------------------------------------------------------------------------- 1 | array1 = [3, 2, 1] 2 | array2 = [100, 200, 300] # ≡ 3 | print(array1.concat(array2)) # [ 3, 2, 1, 100, 200, 300 ] 4 | 5 | print("\n") 6 | # add: 7 | array1 = [3, 2, 1] 8 | array2 = [100, 200, 300] 9 | array = array1 + array2 # ≡ 10 | print(array) # [ 3, 2, 1, 100, 200, 300 ] -------------------------------------------------------------------------------- /snippets/rb/array/move/move.rb: -------------------------------------------------------------------------------- 1 | sourceArray = [5, 4, 3, 2, 1] 2 | destinationArray = ['a', 'b', 'c'] 3 | sourceStart = 1 # 0: first item, 1: second item... 4 | destinationIndex = 2 # 2: third item... 5 | count = 3 6 | print(sourceArray) # [ 5, 4, 3, 2, 1 ] 7 | print("\n") 8 | print(destinationArray) # [ 'a', 'b', 'c' ] 9 | print("\n") 10 | destinationArray = destinationArray[0,destinationIndex] + sourceArray[sourceStart,(sourceStart + count)] + destinationArray[destinationIndex, (destinationArray.length() - 1)] # ≡ 11 | sourceArray.slice!(sourceStart,(sourceStart + count - 1)) # ≡ 12 | print(sourceArray) # [ 5, 1 ] 13 | print("\n") 14 | print(destinationArray) # [ 'a', 'b', 4, 3, 2, 'c' ] -------------------------------------------------------------------------------- /snippets/rb/array/replace/replace.rb: -------------------------------------------------------------------------------- 1 | array = [3, 2, 1] 2 | index = 1 # 0: first item, 1: second item... 3 | item = 100 4 | print(array) # [3, 2, 1] 5 | print("\n") 6 | array[index] = item # ≡ 7 | print(array) # [3, 100, 1] -------------------------------------------------------------------------------- /snippets/rb/array/reverse/reverse.rb: -------------------------------------------------------------------------------- 1 | array = [1, 2, 3, 4, 5] 2 | print(array) # [ 1, 2, 3, 4, 5 ] 3 | print("\n") 4 | print(array.reverse()) # [5, 4, 3, 2, 1] -------------------------------------------------------------------------------- /snippets/rb/array/search/search.rb: -------------------------------------------------------------------------------- 1 | array = [5, 4, 3, 2, 1] 2 | item = 4 3 | index = array.index(item) # 0: first item, 1: second item... ≡ 4 | print(index) # 1 -------------------------------------------------------------------------------- /snippets/rb/array/set/set.rb: -------------------------------------------------------------------------------- 1 | array = [3, 2, 1] 2 | index = 1 # 0: first item, 1: second item... 3 | item = 100 4 | print(array) # [3, 2, 1] 5 | print("\n") 6 | array[index] = item # ≡ 7 | print(array) # [3, 100, 1] 8 | print("\n") -------------------------------------------------------------------------------- /snippets/rb/array/shuffle/shuffle.rb: -------------------------------------------------------------------------------- 1 | array = [1, 2, 3, 4, 5] 2 | print(array.shuffle()) -------------------------------------------------------------------------------- /snippets/rb/array/split/split.rb: -------------------------------------------------------------------------------- 1 | separator = '5-4-3-2-1' 2 | string = separator.split('-') # ≡ 3 | print(string) -------------------------------------------------------------------------------- /snippets/rb/array/var array/var.rb: -------------------------------------------------------------------------------- 1 | array = [] 2 | initializedArray = [10, 2.3, "abc"] 3 | multidimensionalArray = [['xyz', 99], [42, 3.14]] -------------------------------------------------------------------------------- /snippets/rb/const/const.rb: -------------------------------------------------------------------------------- 1 | # as function: 2 | def number() 3 | return 10 4 | end 5 | 6 | def decimal() 7 | return 2.3 8 | end 9 | 10 | def string() 11 | return "Hello there." # ≡ 12 | end 13 | 14 | def array() 15 | return [2.3, 'Hello there.', [1, 2], {"a": 1, 'b': 2}] 16 | end 17 | 18 | def dictionary() 19 | return {"number": 2.3, 'list': [1, 2], "values": {'a': 1, "b": 2}} 20 | end 21 | 22 | print(string()) # Hello there. -------------------------------------------------------------------------------- /snippets/rb/sample rb/sample.rb: -------------------------------------------------------------------------------- 1 | puts "Hello World" -------------------------------------------------------------------------------- /snippets/rs/array/add/add.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | let mut array = vec![3, 2]; 4 | let item = 1; 5 | println!("{array:?}"); // [3, 2] 6 | array.push(item); // ≡ 7 | println!("{array:?}"); // [3, 2, 1] 8 | } -------------------------------------------------------------------------------- /snippets/rs/array/clear remove/clear.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | let mut array = vec![1, 2, 3]; 4 | println!("{array:?}"); // [1, 2, 3] 5 | array.clear(); // ≡ 6 | println!("{array:?}"); // [] 7 | } -------------------------------------------------------------------------------- /snippets/rs/array/count/count.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | let mut array = vec![3, 2, 1]; 4 | let array_size = array.len(); // ≡ 5 | println!("{array_size:?}"); // 3 6 | } -------------------------------------------------------------------------------- /snippets/rs/array/cut/cut.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | let mut array = vec![5, 4, 3, 2, 1]; 4 | let start = 1; // 0: first item, 1: second item... 5 | let count = 3; 6 | println!("{array:?}"); // [5, 4, 3, 2, 1] 7 | let array_cut: Vec<_> = array.drain(start..(start + count)).collect(); // ≡ 8 | println!("{array:?}"); // [5, 1] 9 | println!("{array_cut:?}"); // [4, 3, 2] 10 | } -------------------------------------------------------------------------------- /snippets/rs/array/empty/empty.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | let mut array = vec![]; 4 | if array.is_empty() { println!("array is empty") }; // ≡ 5 | array.push(100); 6 | if !array.is_empty() { println!("array has items") }; // ≡ 7 | array.clear(); 8 | if array.is_empty() { println!("array is empty again") }; 9 | } -------------------------------------------------------------------------------- /snippets/rs/array/get/get.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | let mut array = vec![5, 4, 3, 2, 1]; 4 | let index = 1; // 0: first item, 1: second item... 5 | let item = array[index]; // ≡ 6 | println!("{item}"); // 4 7 | } -------------------------------------------------------------------------------- /snippets/rs/array/remove clear/remove.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | let mut array = vec![5, 4, 3, 2, 1]; 4 | let index = 1; // 0: first item, 1: second item... 5 | println!("{array:?}"); // [5, 4, 3, 2, 1] 6 | array.remove(index); // ≡ 7 | println!("{array:?}"); // [5, 3, 2, 1] 8 | 9 | // many items: 10 | let mut array = vec![5, 4, 3, 2, 1]; 11 | let start = 1; // 0: first item, 1: second item... 12 | let count = 3; 13 | println!("{array:?}"); // [5, 4, 3, 2, 1] 14 | array.drain(start..(start + count)); // ≡ 15 | println!("{array:?}"); // [5, 1] 16 | 17 | // many items at the end: 18 | let mut array = vec![5, 4, 3, 2, 1]; 19 | let start = 2; // 0: first item, 1: second item... 20 | println!("{array:?}"); // [5, 4, 3, 2, 1] 21 | array.truncate(start); // ≡ 22 | println!("{array:?}"); // [5, 4] 23 | } -------------------------------------------------------------------------------- /snippets/rs/array/set/set.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | let mut array = vec![3, 2, 1]; 4 | let index = 1; // 0: first item, 1: second item... 5 | let item = 100; 6 | println!("{array:?}"); // [3, 2, 1] 7 | array[index] = item; // ≡ 8 | println!("{array:?}"); // [3, 100, 1] 9 | } -------------------------------------------------------------------------------- /snippets/rs/const/const.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | const NUMBER: i64 = 10; 4 | const DECIMAL: f64 = 2.3; 5 | const STRING: &str = "Hello there."; // ≡ 6 | const ARRAY_NUMBERS: &'static [i64] = &[1, 2, 3, 4, 5]; 7 | const ARRAY_DECIMALS: &'static [f64] = &[2.3, 3.14, 0.99]; 8 | const ARRAY_STRINGS: &'static [&'static str] = &["abc", "xyz", "123"]; 9 | println!("{STRING}"); // Hello there. ≡ 10 | } -------------------------------------------------------------------------------- /snippets/rs/sample rs/sample.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | println!("Hello, World!"); 4 | } -------------------------------------------------------------------------------- /snippets/rs/var/var.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | let mut number = 10; 4 | let mut decimal = 2.3; 5 | let mut string = "Hello there."; // ≡ 6 | let mut array_numbers = vec![1, 2, 3, 4, 5]; 7 | let mut array_decimals = vec![2.3, 3.14, 0.99]; 8 | let mut array_strings = vec!["abc", "xyz", "123"]; 9 | println!("{string}"); // Hello there. ≡ 10 | string = "Goodbye!"; // ≡ 11 | println!("{string}"); // Goodbye! ≡ 12 | } --------------------------------------------------------------------------------