You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
980 B
23 lines
980 B
2 years ago
|
|
||
|
|
||
|
fun reverse list/0,1# {@@ok/result.= do_reverse $list [list]}
|
||
|
fun do_reverse h/0/head,t/0/tail,reversed/1 {tailcall @@ok/result.= do_reverse $t [list $h {*}$reversed]}
|
||
|
fun do_reverse 0/0/#,reversed/1 {return $reversed}
|
||
|
|
||
|
|
||
|
|
||
|
#2023-06 initial punk version.. creates string rep, no compiled pattern matching - extremely slow
|
||
|
#set x [list a b c d e f g h i j];list
|
||
|
#P% llength $x
|
||
|
#- 10
|
||
|
#P% rep $x
|
||
|
#- value is a list with a refcount of 4, object pointer at 00000000097F65F0, internal representation 0000000004ABCE90:0000000000000000, no string representation
|
||
|
#P% reverse $x; list
|
||
|
#P% rep $x
|
||
|
#- value is a list with a refcount of 4, object pointer at 00000000097F65F0, internal representation 0000000004ABCE90:0000000000000000, string representation "a b c d e f #g..."
|
||
|
#P% time {reverse $x} 100
|
||
|
#- 2457.0330000000004 microseconds per iteration
|
||
|
#P% time {reverse $x} 1000
|
||
|
#- 2460.8575 microseconds per iteration
|
||
|
|