Skip to content

Instantly share code, notes, and snippets.

Red [
author: "Nędza Darek"
date: 2019-11-09
license: {
- no warranties
- use/modify everywhere
- just mention (this gist/github or something like this)
}
version: #0.0.1.preview2
updates: {
@nedzadarek
nedzadarek / rejoin*.red
Last active June 21, 2019 14:53
rejoin using mold
rejoin*: func ["Reduces and joins a block of values."
block [block!] "Values to reduce and join"
][
if empty? block: reduce block [return block]
append either (series? first block) [copy first block] [
mold first block
] next block]
some_word: "foo:"
word: to-word "some_word"
@nedzadarek
nedzadarek / linked_list.red
Created June 21, 2019 13:03
Linked list using only `path!`
Red [
author: {Nędza Darek}
license: {
- use/modify everywhere
- point to this gist/github
- no warranties
}
version: 0.0.1
]
p1: to-path bind [next a] context [next: 11]
@nedzadarek
nedzadarek / random_loot.red
Last active June 5, 2019 09:52
Generating chance (win/fail) based on % (float) - after each 100 tries it increases it's chances.
Red[
author: {Nędza Darek}
version: 0.0.2
license: {
- point to this gist/github
- no warranties
- use/modify everywhere
}
]
float-incr: function [v] [
Red [
author: "Nędza Darek"
license: "Just link to this gist"
]
gitter-source: https://gitter.im/red/help?at=5ce3990b9d64e537bce51706
k-manual: https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Manual.md
; The primitive verbs in K are either monadic (have only one argument - right, or x) or
; dyadic (have two arguments - left and right, or x and y).
; m is monadic, d is dyadic
@nedzadarek
nedzadarek / deep_each.red
Created May 20, 2019 13:53
each for nested blocks
each: function [a[block!] b [function!]] [
collect [
foreach el a [
either block? el [
keep/only each el :b
][
keep b el
]
]
]
[datatype! ": "]
error
[unset! ": "]
error
[none! ": "]
error
[logic ": "]
error
[char ": "]
error
||=: make op! func ['a b] [either value? a [return get a] [set a b return b]]
a: 4
a ||= 3
; == 4
c ;*** Script Error: c has no value
c ||= 42
; == 42
c
; == 42
system/view/auto-sync?: no
canvas-size: 900x900
ball-speed: 1x1
ball-size: 10
ball-spacing: 36x1
balls-number: 1000
balls: make block! 1500
balls2: make block! 1500
draw-block: []
ball-color: does [as-color random 255 210 222]
@nedzadarek
nedzadarek / text_list_elements_dissaperance.red
Created November 3, 2018 22:59
When you click text list sometimes it disappear.
Red[]
l: layout[
do [
number-of-colors: 0
select-data: function [
list
] [
select list/data to-string list/selected
]
]