mirror of
https://github.com/zeroflag/fcl.git
synced 2025-01-11 20:01:10 +01:00
share button + hist
This commit is contained in:
parent
20a3e249a9
commit
74aabb6445
2 changed files with 17 additions and 4 deletions
|
@ -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 ;
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue