mirror of
https://github.com/zeroflag/fcl.git
synced 2025-01-12 20:01:25 +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 + ;
|
: hist ( c -- m )
|
||||||
|
<map> -> tbl {
|
||||||
: nfib ( n -- .. ) -> n
|
-> elem
|
||||||
0 1 { fib } n times ;
|
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());
|
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() {
|
private String transcript() {
|
||||||
return transcript.content();
|
return transcript.content();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue