This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Expr = Val Int | Add Expr Expr | |
data Op = EVAL Expr | ADD Int | |
value :: Expr -> Int | |
value e = eval e [] | |
eval :: Expr -> [Op] -> Int | |
eval (Val n) stack = exec stack n | |
eval (Add lexpr rexpr) stack = eval lexpr ((EVAL rexpr):stack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{rc::{Rc, Weak}, cell::RefCell}; | |
struct Node<T>{ | |
data: T, | |
next: Option<Rc<RefCell<Node<T>>>>, | |
prev: Option<Weak<RefCell<Node<T>>>>, | |
} | |
struct Doublili<T> { | |
head: Option<Rc<RefCell<Node<T>>>>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct A { | |
value: *mut i64, | |
} | |
impl A { | |
fn new() -> A { | |
A{value: std::ptr::null_mut()} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Node { | |
value: i64, | |
next: Option<Box<Node>>, | |
} | |
struct List { | |
head: Option<Box<Node>>, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::rc::Rc; | |
use std::cell::RefCell; | |
struct A { | |
value: Rc<RefCell<Vec<i64>>>, | |
} | |
struct B { | |
value: Rc<RefCell<Vec<i64>>>, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fmt; | |
struct Element<T> { | |
value: T, | |
next: Option<Box<Element<T>>>, | |
} | |
struct List<T> { | |
head: Option<Box<Element<T>>>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fmt; | |
struct Element<T> { | |
value: T, | |
next: Option<Box<Element<T>>>, | |
} | |
struct List<T> { | |
head: Option<Box<Element<T>>>, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'package) | |
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos)) | |
(not (gnutls-available-p)))) | |
(proto (if no-ssl "http" "https"))) | |
(when no-ssl | |
(warn "\ | |
Your version of Emacs does not support SSL connections, | |
which is unsafe because it allows man-in-the-middle attacks. | |
There are two things you can do about this warning: | |
1. Install an Emacs version that does support SSL and be safe. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* MIT License | |
* | |
* Copyright (c) 2018 Mike Taghavi <mitghi[at]gmail.com> | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def digits(n): | |
result = [] | |
l = 0 | |
while n > 0: | |
d = n % 10 | |
result.insert(0, d) | |
n = n // 10 | |
l += 1 | |
return (l, result) |