Muhammad Attiyah - Home
http://muattiyah.com/
Recent content on Muhammad Attiyah - HomeHugo -- gohugo.ioen-usSat, 16 Jun 2018 23:51:11 +0200Python Internals – CPython Bytecode
http://muattiyah.com/posts/python-internals-cpython-bytecode/
Sat, 16 Jun 2018 23:51:11 +0200http://muattiyah.com/posts/python-internals-cpython-bytecode/In this post, I am gonna walk you through compiling python code to CPython bytecode, what code objects are, how to construct them, how to disassemble them, and how to decompile them.
I will be using CPython 3.6.5.
A simple example >>> codestr = """print('Witness me!')""" >>> compiled_codestr = compile(codestr, '<string>', 'exec') >>> type(compiled_codestr) <class 'code'> Whoo, we have created our first code object.
We passed arguments to the compile function as follows:ADTs (Algebraic Data Types) in Haskell
http://muattiyah.com/posts/haskell-adts/
Wed, 30 May 2018 00:00:00 +0000http://muattiyah.com/posts/haskell-adts/Algebraic Data Types are a way for us to define types like the ones that come with Haskell e.g. Bool and Int.
Single Constructor Without Arguments The most simple data type we can construct in Haskell is a type with a single constructor,
data Frame = MkFrame x = MkFrame Examining the type in ghci
:> :type MkFrame MkFrame :: Frame :> :type x x :: Frame In this example, we use the data keyword to signify a Data Type, Frame is the name of that type and we refer to it as a Type Constructor.Mathematical Induction
http://muattiyah.com/posts/mathematical-induction/
Mon, 12 Jun 2017 00:00:00 +0000http://muattiyah.com/posts/mathematical-induction/Suppose you want to sum up the first 10 natural numbers 1, 2, 3, ...
The most obvious way to do it would be to add the numbers consecutively like so: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
No big deal, but now you want to sum the first 1000 natural numbers i.e. 1, 2, 3, .