Skip to content
Snippets Groups Projects
Commit 47f1a8e3 authored by Love Arreborn's avatar Love Arreborn
Browse files

initial commit

parents
No related branches found
No related tags found
No related merge requests found
###############################################################################
# General OS and Editor junk
###############################################################################
.DS_Store
Thumbs.db
*~
*.swp
*.swo
*.tmp
*.bak
.vscode/
.idea/
*.iml
*.log
###############################################################################
# Ruby
###############################################################################
.bundle/
vendor/
coverage/
doc/
pkg/
yardoc/
.ruby-version
.ruby-gemset
Gemfile.lock # Might be committed in many projects, but ignoring here by request
###############################################################################
# Python
###############################################################################
__pycache__/
*.py[cod]
*.pyd
*.pyo
*.pyc
*.whl
.pytest_cache/
*.egg-info/
.venv/
env/
venv/
.python-version
###############################################################################
# JavaScript / TypeScript
###############################################################################
node_modules/
dist/
build/
npm-debug.log*
yarn.lock
package-lock.json
*.d.ts
.parcel-cache/
.turbo/
.eslintcache
###############################################################################
# C / C++
###############################################################################
*.o
*.obj
*.so
*.exe
*.dll
*.out
*.dylib
*.a
*.lib
*.pch
*.pdb
# Any local build directories (commonly named build or bin)
build/
bin/
.ccls-cache/
cquery.cache/
###############################################################################
# Rust
###############################################################################
target/
*.rs.bk
Cargo.lock # Often committed for binaries, but ignoring if you prefer
.cargo/
.rustc/
###############################################################################
# Go
###############################################################################
bin/
pkg/
*.exe
go.sum
coverage.out
###############################################################################
# C#
###############################################################################
[Bb]in/
[Oo]bj/
*.user
*.suo
*.csproj.user
*.dll
*.exe
*.pdb
###############################################################################
# Java
###############################################################################
*.class
*.jar
*.war
*.ear
target/
build/
.gradle/
.settings/
.project
.classpath
*.iml
###############################################################################
# Elixir
###############################################################################
_build/
deps/
*.ez
mix.lock # Often committed, but ignoring if you prefer
.elixir_ls/
###############################################################################
# Haskell
###############################################################################
dist/
dist-newstyle/
.stack-work/
*.hi
*.o
*.dyn_o
*.dyn_hi
*.chi
cabal.project.local
stack.yaml.lock
###############################################################################
# Bash
###############################################################################
# Generally, Bash doesn't produce compiled artifacts, so no special ignores here
# beyond the general OS/editor lines above.
###############################################################################
# Lisp (Common Lisp, SBCL, etc.)
###############################################################################
*.fas
*.fasl
*.ufsl
*.x86f
*.pfsl
.cache/
# Bash
Varför använda Bash?
Som nämnt under föreläsning 5 kan Bash anses vara ett DSL vars syfte är att ge
terminalskalet mer avancerad funktionalitet. Det är inte helt ovanligt att många
kommandon ni kör i terminalen har ett s.k. shell-script i bakgrunden, alltså en
Bash-fil som körs när kommandot skrivs in.
## Köra koden
1. Körs enklast direkt i terminalen
```bash
bash example.sh
```
#!/usr/bin/env bash
manipulate() {
local arr=("$@")
local new_arr=()
for x in "${arr[@]}"; do
new_arr+=($((x + 5)))
done
echo "${new_arr[@]}"
}
echo "Hello world!"
my_list=(10 15 20 25 30)
result=$(manipulate "${my_list[@]}")
echo "Result: $result"
# C++
## How to Compile and Run
1. Ensure g++ is installed (check with `g++ --version`).
2. Compile:
```bash
g++ -o example example.cpp
```
3. Run:
```bash
./example
```
#include <iostream>
#include <vector>
std::vector<int> manipulate(const std::vector<int>& arr) {
std::vector<int> newArr;
for (int x : arr) {
newArr.push_back(x + 5);
}
return newArr;
}
int main() {
std::cout << "Hello world!" << std::endl;
std::vector<int> myList = {10, 15, 20, 25, 30};
std::vector<int> result = manipulate(myList);
std::cout << "Result: ";
for (int x : result) {
std::cout << x << " ";
}
std::cout << std::endl;
return 0;
}
# C
## How to Compile and Run
1. Ensure gcc is installed (check with `gcc --version`).
2. Compile:
```bash
gcc -o example example.c
```
3. Run:
```bash
./example
```
c/add.c 0 → 100644
#include <stdio.h>
void manipulate(const int arr[], int size, int out[]) {
for (int i = 0; i < size; i++) {
out[i] = arr[i] + 5;
}
}
int main() {
printf("Hello world!\n");
int myList[5] = {10, 15, 20, 25, 30};
int result[5];
manipulate(myList, 5, result);
printf("Result: ");
for (int i = 0; i < 5; i++) {
printf("%d ", result[i]);
}
printf("\n");
return 0;
}
# Elixir
## How to Run
1. Ensure Elixir is installed (check with `elixir --version`).
2. Run the file directly:
```bash
elixir example.exs
```
defmodule Example do
def manipulate(arr) do
for x <- arr, do: x + 5
end
def main do
IO.puts("Hello world!")
my_list = [10, 15, 20, 25, 30]
result = manipulate(my_list)
IO.inspect(result, label: "Result")
end
end
Example.main()
# Go
## How to Run
1. Ensure Go is installed (check with `go version`).
2. Run the file with:
```bash
go run example.go
```
package main
import "fmt"
func manipulate(arr []int) []int {
newArr := make([]int, len(arr))
for i, v := range arr {
newArr[i] = v + 5
}
return newArr
}
func main() {
fmt.Println("Hello world!")
myList := []int{10, 15, 20, 25, 30}
result := manipulate(myList)
fmt.Println("Result:", result)
}
# Haskell
## How to Run
1. Ensure GHC or the Haskell platform is installed (check with `ghc --version`).
2. Option A: Interpret directly
```bash
runghc example.hs
```
3. Option B: Compile and run
```bash
ghc example.hs -o example
./example
```
manipulate :: [Int] -> [Int]
manipulate [] = []
manipulate (x:xs) = (x + 5) : manipulate xs
main :: IO ()
main = do
putStrLn "Hello world!"
let myList = [10, 15, 20, 25, 30]
let result = manipulate myList
putStrLn ("Result: " ++ show result)
# Java
## How to Compile and Run
1. Ensure the JDK is installed (check with `javac -version`).
2. Compile:
```bash
javac Main.java
```
3. Run:
```bash
java Main
```
public class Main {
public static int[] manipulate(int[] arr) {
int[] newArr = new int[arr.length];
for (int i = 0; i < arr.length; i++) {
newArr[i] = arr[i] + 5;
}
return newArr;
}
public static void main(String[] args) {
System.out.println("Hello world!");
int[] myList = {10, 15, 20, 25, 30};
int[] result = manipulate(myList);
System.out.print("Result: ");
for (int x : result) {
System.out.print(x + " ");
}
System.out.println();
}
}
## JavaScript (README-javascript.md)
````markdown
# JavaScript
## How to Run
1. Ensure Node.js is installed (check with `node --version`).
2. Run the file with:
```bash
node example.js
```
````
function manipulate(arr) {
const newArr = [];
for (let i = 0; i < arr.length; i++) {
newArr.push(arr[i] + 5);
}
return newArr;
}
console.log("Hello world!");
const myList = [10, 15, 20, 25, 30];
const result = manipulate(myList);
console.log("Result:", result);
# Common Lisp
## How to Run
1. Ensure a Lisp implementation is installed (e.g. SBCL: `sbcl --version`).
2. Run the file:
```bash
sbcl --script example.lisp
```
(defun manipulate (lst)
(let ((result '()))
(dolist (x lst (reverse result))
(push (+ x 5) result))))
(defun main ()
(format t "Hello world!~%")
(let* ((my-list '(10 15 20 25 30))
(result (manipulate my-list)))
(format t "Result: ~a~%" result)))
(main)
# Python
## How to Run
1. Ensure Python is installed (check with `python3 --version`).
2. Run the file with:
```bash
python3 example.py
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment