fork(3) download
  1. function len(list, count){
  2. count = count || 0;
  3. return list.next ? len(list.next, count + 1) : list.value !== undefined ? count + 1 : count
  4. }
  5.  
  6. var list = {
  7. value: 1,
  8. next: {
  9. value: 2,
  10. next: {
  11. value: 3,
  12. next: {
  13. value: 4,
  14. next: null
  15. }
  16. }
  17. }
  18. };
  19.  
  20. print(len(list))
  21.  
  22. print(len({}))
  23.  
  24. print(len({value:0, next:null}))
Success #stdin #stdout 0.02s 30152KB
stdin
Standard input is empty
stdout
4
0
1