Skip to content

Instantly share code, notes, and snippets.

@kermitaner
kermitaner / huffy.red
Created February 1, 2018 22:04
huffman coding in Red, example for Rosetta code task...
Red [file: %huffy.red]
;; message to encode:
msg: "this is an example for huffman encoding"
;;map to collect leave knots per uniq character of message
m: make map! []
knot: make object! [
left: right: none ;; pointer to left/right sibling
@kermitaner
kermitaner / vign1.red
Last active January 3, 2020 12:36
vigenere encrypting with gui
Red [needs: 'view]
CRLF: copy "^M^/" ;; constant for 0D 0A line feed
;;------------------------------------
crypt: func ["function to en- or decrypt message from textarea tx1"
/decrypt "decrypting switch/refinement" ][
;;------------------------------------
;; when decrypting we have to remove the superflous newlines
;; and undo the base64 encoding first ...
@kermitaner
kermitaner / _utf8.red
Created September 17, 2017 20:00
;; utf8 conversion red from win1252 codepage
Red[]
;; read win1252 textfile , convert to utf8 text string / lines with _myread %filename
;;#include %../inc/_utf8.red
_m: []
insert/dup _m #{} 255
;-----------------------------------------
_ini: function [/extern _m ][
;-----------------------------------------
;; erzeugen ut8 map dec -> utf8