Re: Elementary but surprisingly difficult.



On May 24, 6:23 pm, Slava Pestov <sl...@xxxxxxxxx> wrote:
On May 24, 4:36 pm, Bernd Paysan <bernd.pay...@xxxxxx> wrote:

: uniquify ( addr u -- addr u' )
over >r bounds dup dup c@ 2swap 1+ ?DO
I c@ tuck <> IF swap 1+ 2dup c! swap THEN LOOP
drop r> swap over - ;

This is why stack-based languages have a reputation of unreadability.

``uniquify'' ... I dunno, that word looks pretty readable to me.

Its *definition* is underfactored, of course, and underfactored
definitions are always hard to read, but

uniquify ( addr u -- addr u' )
trim duplicate characters from a sorted string, in place

.... seems pretty readable to me.
.



Relevant Pages

  • Re: Forth Frustrations
    ... dup c@ swap ... i rdelta width */ + addr c! ... LOOP; ... 1 D+ \ address buffer will never overflow ...
    (comp.lang.forth)
  • Re: vm-pageout-throttling.patch: hanging in throttle_vm_writeout/blk_congestion_wait
    ... By swapping to a loop device over a file, ... and putting the filesystem back under swap. ... Device backed loop is capable of encrypting swap on 2.4 ... File backed loops can't be used for swap. ...
    (Linux-Kernel)
  • Re: Efficient high memory
    ... > the application without swap and without interference from the ... > OOM-killer. ... dunno anything about your app and what it's ...
    (comp.os.linux.setup)
  • Re: [PATCH, RFC/T] Fix handling of write failures to swap devices
    ... SIGBUS, so that will have to be found and fixed individually. ... Notice swap write errors during page reclaim, ... The patch below is a diff on top of the patch linked to above so you can ... locking to try_to_unusebut this is complicated by the retry loop. ...
    (Linux-Kernel)
  • Re: Royal Institution Christmas lectures
    ... The bubble-sort algorithm seemed rather flawed --- the termination condition was something like "are they in the correct order?", rather than a check on whether a swap had occurred in the loop just completed. ... or only the first compared pair resulted in a swap, ... last = array + nmemb; ...
    (comp.programming)