Skip to content

Instantly share code, notes, and snippets.

@Lorenzobattistela
Lorenzobattistela / uno.bend
Created July 2, 2024 22:07
UNO! This is a 2 player uno simulation written in bend!
# --------------------------
# optimization possibility: use List/got instead of successive removes + igets
type Option:
None
Some { value }
def List/got(idx,list):
switch idx:
@Lorenzobattistela
Lorenzobattistela / install.sh
Last active April 28, 2024 12:27
Shell script to install needed tools from scratch
#/bin/bash
echo "Hello! This is a fresh installation script for my ubuntu!"
if [ $(id -u) -ne 0 ]; then
echo Please run this script as root or using sudo!
exit
fi
echo "This script will install some default needed applications (from my POV) and ask if you want others."

Dunder methods

Usually implemented when we want objects to support and interact with fundamental elements of the language, as:

  • Collections
  • Attribute access
  • Iteration (including async for)
  • Operator overloading
  • invoking functions and methods
  • representation and string formatting
  • async programing using await
  • creation and destruction of objects
(* Lists and Patterns *)
(* An OCaml list is an immutable finite sequence of elements of the same type. *)
open Base;
let list = [1;2;3]
let list = 1 :: 2 :: 3 :: []
(* The way in which the :: operator attaches elements to the front of a list reflects the fact that ocaml lists are in fact signly linked lists. *)
import sys
class Node(): # Defines a node, that holds a state value, a parent and the action taken to get there.
def __init__(self, state, parent, action):
self.state = state
self.parent = parent
self.action = action
import sys
class Node(): # Defines a node, that holds a state value, a parent and the action taken to get there.
def __init__(self, state, parent, action):
self.state = state
self.parent = parent
self.action = action
Repeat:
1- If frontier is empty:
-Stop. There is no solution to the problem
2- Remove a node from the frontier. This is the node that will be considered
3- If the node contains the goal state:
-Return the solution. Stop.
Else: