Hardfuck

Hardfuck is a Brainfuck derivative created by User:Zayne (why am I not surprised) and as the name suggests it is supposed to be harder than Brainfuck.
== Commands ==
Command	Description
> 	Move the pointer to the right
< 	Move the pointer to the left
+ 	Increment the memory cell under the pointer
- 	Decrement the memory cell under the pointer
. 	Get an input, output the input and store it at the pointer's cell
, 	Output the cell before the pointer
[ 	Jumps to the nearest ] if the value of the cell before the pointer is 0
] 	Jump back to the matching [ if the value of the cell after the pointer is nonzero
@ 	Stores the answer to the cell under the pointer multiplied by 4 in the cell before the pointer
/ 	Returns to the first cell
Everything else is a comment.
== Examples ==
Hello World
 sets the cell to 18
 >>>>>>>>>>>>>>>>>>
 multiplies 18 by 4 which is equal to 72 and stores it in cell 17
 @
 goes to cell 50
 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 multiplies 50 by 4 which is equal to 200 and stores it in cell 49
 @
 we go to cell 49
 <
 and then do 99 negatives
 ---------------------------------------------------------------------------------------------------
 now cell 49 has the e we can go to cell 51
 >>
 now 50 is 204
 @
 we go back
 <
 and then
 ------------------------------------------------------------------------------------------------
 we have our first l
 >
 I'm being lazy
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 second l
 >
 o
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 now for the space
 >
 ++++++++++++++++++++++++++++++++
 now to do the W
 >
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 and the o
 >
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 and the r
 >
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 l
 >
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 d
 >
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 now to print it out
 />>>>>>>>>>>>>>>>>>,>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>,>,>,>,>,>,>,>,>,>,
Minified?
 >>>>>>>>>>>>>>>>>>@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>@<--------------------------------------------------------------------------------------------------->>@<------------------------------------------------------------------------------------------------>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/>>>>>>>>>>>>>>>>>>,>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>,>,>,>,>,>,>,>,>,>,
==Interpreters==
The following Common Lisp code realizes a very simple Hardfuck interpreter:
 
 (defun interpret-hardfuck (code)
 "Interprets the Hardfuck CODE and returns ``NIL."
 (declare (type string code))
 (when (plusp (length code))
 (let ((position 0)
 (character (char code 0)))
 (declare (type fixnum position) (type (or null character) character))
 (flet ((to-next-character ()
 (if (< position (1- (length code)))
 (setf character (char code (incf position)))
 (setf character NIL)))
 (to-previous-character ()
 (if (plusp position)
 (setf character (char code (decf position)))
 (setf character NIL))))
 (let ((memory (make-hash-table :test #'eql))
 (pointer 0))
 (declare (type hash-table memory) (type integer pointer))
 (loop do
 (case character
 ((NIL)
 (loop-finish))
 (#\>
 (incf pointer)
 (to-next-character))
 (#\<
 (decf pointer)
 (to-next-character))
 (#\+
 (incf (gethash pointer memory 0))
 (to-next-character))
 (#\-
 (decf (gethash pointer memory 0))
 (to-next-character))
 (#\.
 (format T "~&Please enter a character: ")
 (let ((input (read-char)))
 (declare (type character input))
 (write-char input)
 (setf (gethash pointer memory) (char-code input)))
 (to-next-character))
 (#\,
 (write-char (code-char (gethash (1- pointer) memory 0)))
 (to-next-character))
 (#\[
 (cond
 ((zerop (gethash (1- pointer) memory 0))
 (to-next-character)
 (loop with level of-type fixnum = 0 do
 (case character
 ((NIL)
 (error "'[' not followed by ']'."))
 (#\[
 (incf level))
 (#\]
 (cond
 ((zerop level)
 (loop-finish))
 (T
 (decf level)
 (to-next-character))))
 (otherwise
 (to-next-character)))))
 (T
 (to-next-character))))
 (#\]
 (cond
 ((zerop (gethash (1+ pointer) memory 0))
 (to-next-character))
 (T
 (to-previous-character)
 (loop with level of-type fixnum = 0 do
 (case character
 ((NIL)
 (error "']' not preceded by '['."))
 (#\]
 (incf level))
 (#\[
 (cond
 ((zerop level)
 (loop-finish))
 (T
 (decf level)
 (to-previous-character))))
 (otherwise
 (to-previous-character)))))))
 (#\@
 (setf (gethash (1- pointer) memory 0) (* pointer 4))
 (to-next-character))
 (#\/
 (setf pointer 0)
 (to-next-character))
 (otherwise
 (to-next-character)))))))))
GitHub is dedicated to Common Lisp implementations of Hardfuck.
Category:Languages
Category:Brainfuck_derivatives
Category:Cell-based
Category:Turing complete
Category:Turing tarpits
Category:Low-level
Category:2017