share button + hist

This commit is contained in:
zeroflag 2021-06-27 13:36:18 +02:00
parent 20a3e249a9
commit 74aabb6445
2 changed files with 17 additions and 4 deletions

View file

@ -1,4 +1,11 @@
: fib ( n1 n2 -- n1 n2 n3 ) 2dup + ;
: nfib ( n -- .. ) -> n
0 1 { fib } n times ;
: hist ( c -- m )
<map> -> tbl {
-> elem
tbl elem at -> count
count nil = if
tbl elem 1 put
else
tbl elem count 1+ put
then
} each
tbl ;

View file

@ -1118,6 +1118,12 @@ public class FclTest {
assertEquals(30, fcl.pop().intValue());
}
@Test
public void testHist() {
assertEquals("#[ 'a' 2 'b' 3 'c' 1 ]#", evalPop("'ababbc' hist").toString());
assertEquals("#[ ]#", evalPop("'' hist").toString());
}
private String transcript() {
return transcript.content();
}